I believe Constructors
and Destructors
in base class
cannot be inherited by derived classes
of the base class. Is my understanding correct.
Your understanding is correct. For example, if you have
class Base
{
Base(int i) {}
};
class Derived: public Base {};
Derived d(3);
This will not compile because the Base constructor is not inherited. Note that default and copy constructor are created by the compiler if possible, and call the corresponding constructor of base classes, therefore for those constructors it looks as if those were inherited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With