Inheritance related question. Is this correct?
People, tell me if this is correct. Im doing this in order to save some code in my constructors, but dont know if its a good practice, a bad one, or incorrect.
Suppose I have two classes, a Control class and a derived Window class (class Window : public Control). They both may point to a Parent, and the pointer is set at construction time.
Control::Control(Parent* parent)
{
m_ParentPtr = parent;
// init stuff
}
Then in the Window constructor:
Window::Window(Parent* parent)
{
// is this correct?
Control::Control(parent);
// init Window related stuff
}
Ok, hope you understand my question. Im also calling a lot the default constructor in some overloaded ones like:
Class::Class()
{
// init basic stuff
}
Class:Class(int foo)
{
m_Foo = foo;
Class::Class(); // call default constructor
}
Thx.