in which case derived class must have its own constructor?
In C++开发者_开发百科, in what case, the derived class must have its own constructor?
what about the three cases: 1) public inheritance; 2) private inheritance; 3) protected inheritance;
Thanks a lot.
All classes that are instantiated always have to have at least one constructor. If you don't provide one, the compiler will provide one instead.
There aren't any special rules for derived classes.
Constructors are not inherited, you have to write them explicitely for the derived class. Destructors are generated automatically, as a default constructor is generated, if the base class has a default constructor.
Constructors are not inherited. Each class needs its own constructors.
精彩评论