c++ - I do not want the derived class to inherit the constructor function of the Base class -
as located @ title.
here example:
#include <iostream> using namespace std; class base { private: int nsize; public: base(){ cout << "i'm base constructor" << endl; } }; class derived : public base { int nmaxsize; public: derived(){ cout << "i'm derived constructor" << endl; } }; int main(){ derived obj; return 0; }
the result:
i'm base constructor i'm derived constructor
you have no choice. best can pass flag base constructor disabling don't want. indicates bad design.
Comments
Post a Comment