P
Paul N
I'm using inheritance - this particular case is to provide a linked
list of attributes of a piece of text (text colour, italic etc) so
that different parts of it can be shown in different ways.
class Attrib : public Listable {
public:
// stuff including where in the text the attribute starts to take
effect
};
class Col_Attrib : public Attrib {
public:
COLORREF col;
// plus more stuff
};
class Ink : public Col_Attrib {
public:
// stuff
};
class Paper : public Col_Attrib {
public:
// stuff
};
Now, if I include a constructor:
Col_Attrib::Col_Attrib(COLORREF incol) : col(incol) { }
then this doesn't, by itself, create constructors for Ink and Paper
taking a COLORREF, does it?
If I did want such constructors, would it be best to include a
constructor as above and then do:
Ink::Ink(COLORREF incol) : Col_Attrib(incol) { }
or would it be better to do:
Ink::Ink(COLORREF incol) : col(incol) { }
directly? The first form seems more natural in terms of the hierarchy,
but the second seems more efficient.
Thanks for any advice.
Paul.
list of attributes of a piece of text (text colour, italic etc) so
that different parts of it can be shown in different ways.
class Attrib : public Listable {
public:
// stuff including where in the text the attribute starts to take
effect
};
class Col_Attrib : public Attrib {
public:
COLORREF col;
// plus more stuff
};
class Ink : public Col_Attrib {
public:
// stuff
};
class Paper : public Col_Attrib {
public:
// stuff
};
Now, if I include a constructor:
Col_Attrib::Col_Attrib(COLORREF incol) : col(incol) { }
then this doesn't, by itself, create constructors for Ink and Paper
taking a COLORREF, does it?
If I did want such constructors, would it be best to include a
constructor as above and then do:
Ink::Ink(COLORREF incol) : Col_Attrib(incol) { }
or would it be better to do:
Ink::Ink(COLORREF incol) : col(incol) { }
directly? The first form seems more natural in terms of the hierarchy,
but the second seems more efficient.
Thanks for any advice.
Paul.