V
viki
There is tree of classes rooted at CBase (single-inheritance). CSub is
derived from CBase, and CBase having virtual member functions, (and
other classes derived from CBase or CSub). All classes must be
assignable.
But much of the code accesses these object through CBase* pointers.
Now, having two CBase* pointers to two objects of actual type CSub,
how do I make assignment smoothly
work through the base-class pointers ? (assigning objects, not
pointers) ?
My question is how can I write assignment operators so as to make the
following to just work:
CBase *x = new CSub;
CBase *y = new CSub;
*x = *y; // how to write assignment operators so that this
will work correctly ?
Is this possible ?
Thanks Viki
derived from CBase, and CBase having virtual member functions, (and
other classes derived from CBase or CSub). All classes must be
assignable.
But much of the code accesses these object through CBase* pointers.
Now, having two CBase* pointers to two objects of actual type CSub,
how do I make assignment smoothly
work through the base-class pointers ? (assigning objects, not
pointers) ?
My question is how can I write assignment operators so as to make the
following to just work:
CBase *x = new CSub;
CBase *y = new CSub;
*x = *y; // how to write assignment operators so that this
will work correctly ?
Is this possible ?
Thanks Viki