c++ - Limitations on pointers to various types within a class family? -
suppose have 4 classes: a,b,c, , d.
a base class. b derived a. c derived a.
d derived b.
i have vectors of each type of object.
i create 5th class excluded related classes (family?), called z. z contains variable points object of class a, called purple.
can create "inter-family" universal pointer doing like: * puniversal;
and point puniversal a,b,c, or d interchangeably object stored in vector of type.. set purple variable of z puniversal?
yes, can that. it's 1 of main benefits of having derived classes.
if have functions in a
should implemented b
or c
, make sure they're virtual.
Comments
Post a Comment