J
Jeff
The derived class below passes a reference to an object in its own
class to its base calss constructor. The code compiles and will run
successfully as long as the base class constructor does not attempt to
access the object -- since m_object is not actually created and
initizialized until after the base constructor has been called.
Any thoughts on the practice below?
class Base
{
public:
Base(Object& ref) {};
~Base() {};
};
class Derived : public Base
{
public:
Derived(int param) : Base(m_object), m_object(param) {};
protected:
Object m_object;
};
class to its base calss constructor. The code compiles and will run
successfully as long as the base class constructor does not attempt to
access the object -- since m_object is not actually created and
initizialized until after the base constructor has been called.
Any thoughts on the practice below?
class Base
{
public:
Base(Object& ref) {};
~Base() {};
};
class Derived : public Base
{
public:
Derived(int param) : Base(m_object), m_object(param) {};
protected:
Object m_object;
};