
22 Oct
2009
22 Oct
'09
1:30 a.m.
Hi, On Thu, Oct 22, 2009 at 5:26 AM, Ireneusz Szpilewski <irek@szpilewski.opole.pl> wrote:
And how exactly are you supposed to make that change at runtime?
What do you suggest?
heart as a member of Me?
Before:
class Me { MyHeart heart; };
After:
class Me { SomebodyElsesHeart heart; }
It can't be done at runtime either.
If MyHeart and SomebodyElsesHeart publicly inherited from say, a Heart (abstract) base class, and if Me's heart member variable was a (smart) pointer to Heart, then you could indeed change the actual (sub)type of the Heart object that a Me object owns at runtime. This is a common technique, methinks. Regards, Eugene