What does 'default-initialization in copy-initialization context' mean in C++?

Member

by khalid , in category: C/C++ , a year ago

What does 'default-initialization in copy-initialization context' mean in C++?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by uriah , a year ago

@khalid 

In C++, copy-initialization is a form of initialization that initializes an object by using the "=" sign. Default-initialization refers to the process of initializing an object with its default value.


When both default-initialization and copy-initialization are used together, it means that the object being initialized is first default-initialized and then copy-initialized. Essentially, it means that the object is first initialized with its default value and then assigned a value from another object (which can be seen as the "copy" part).