Maybe I am misunderstanding. I hope you folks can set me straight.
I understand that I can declare a private constructor in a class. I do this at times in order to simply provide the member functions for the class. But now I am trying to declare a descendant of this class with the private constructor and the compiler is complaining.
class foo {
private:
foo(){}
~foo(){}
};
class foo2: public foo {
public:
foo2(){}
~foo2(){}
};
I would like to prevent someone from creating a foo2 object from being able to call the constructor/destructor directly, but the compiler complains that foo(){} is private.
Is there a different way to prevent access to the constructor/destructor from foo2, or am I just practicing bad design here?
I understand that I can declare a private constructor in a class. I do this at times in order to simply provide the member functions for the class. But now I am trying to declare a descendant of this class with the private constructor and the compiler is complaining.
class foo {
private:
foo(){}
~foo(){}
};
class foo2: public foo {
public:
foo2(){}
~foo2(){}
};
I would like to prevent someone from creating a foo2 object from being able to call the constructor/destructor directly, but the compiler complains that foo(){} is private.
Is there a different way to prevent access to the constructor/destructor from foo2, or am I just practicing bad design here?