C++ - Default Constructor, Copy Constructor, and Assignment

preview_player
Показать описание
When is the default constructor invoked? When is the copy constructor invoked? When is the assignment operator invoked?

Welcome to my C++ learning series! This is a series on various C++ concepts that aims to both shed light on these concepts, test your knowledge, and teach you something along the way. The series will go from easy to hard questions. C++17.

If you would like to see more, please like the video and subscribe.
Рекомендации по теме
Комментарии
Автор

Good example, thanks for this information!

SouravChakraborty-yw
Автор

watched this video and made my own little similar program just to see it myself and this really helped, thank you!

strawberrybob
Автор

This is just copy initialization, you just made up a term that isn't in the standard even the grammar for it 'brace-or-equal-initializer' isn't even close to what you said. It has nothing to do with the type of 'obj1' and 'obj2' being the same type, even being different types that will still be copy initialization. It's pretty straight forward there is no 'obj2' at that point in time for it to even call an assignment operator on, it's calling the constructor based on the type that it is given.

reductor_