A
anongroupaccount
I have an ABC with a protected member that is a reference to an object
of an ABC type:
class ABC
{
public:
virtual ~ABC() = 0;
protected:
AnotherABC& _member;
}
The idea is that my concrete classes will derive from ABC and set
_member in their initialization lists to the specific type of
AnotherABC that the particular class needs. However, this can't be done
as the constructors of the derived classes complain about there being
no default constructor for ABC.
Should I simply replace the reference with a const pointer, or should I
rethink this and save myself from a potentially nasty design flaw? Is
there a design pattern I could use here?
of an ABC type:
class ABC
{
public:
virtual ~ABC() = 0;
protected:
AnotherABC& _member;
}
The idea is that my concrete classes will derive from ABC and set
_member in their initialization lists to the specific type of
AnotherABC that the particular class needs. However, this can't be done
as the constructors of the derived classes complain about there being
no default constructor for ABC.
Should I simply replace the reference with a const pointer, or should I
rethink this and save myself from a potentially nasty design flaw? Is
there a design pattern I could use here?