Boost logo

Boost :

Subject: Re: [boost] [intrusive] rtti_base class proposition
From: Ireneusz Szpilewski (irek_at_[hidden])
Date: 2009-10-22 12:24:14


Eugene Wee wrote:
> Hi,
>
> On Thu, Oct 22, 2009 at 12:08 PM, Ireneusz Szpilewski
> <irek_at_[hidden]> wrote:
>
>> What if MyHeart has SingMySong() method while Heart does not?
>> How can I access it?
>>
>
> Since we are on the topic of RTTI, you could just use say,
> dynamic_cast to convert the Heart* to a MyHeart* and thus call
> SingMySong(). On the other hand, maybe Heart should have such a
> virtual function instead, if it is supposed to be used
> polymorphically.
>
But we were to do a transplant in C++.
I'll try my best, I set up my classes:

class MyHeart:
   public rtti_base, // can do dynamic_cast
   public Heart, // it is human heart
   public MySongSinger // it can SingMySong()
{
  //
};

class Me:
 public rtti_base, // can do dynamic_cast
 public Human // I am a Human, hospital can do
Human->SwapHearts(Heart* newheart);
{
//...
  rtti_base* heart; // initialized to new MyHeart
};

I am ready and waiting in the hospital for a dead person heart.
BANG!!!
Fortunately (for me) there was a car accident and we have 2 bodies:

Joe dead_joe;
AlienHumanoid dead_alien;

What to do next?

Ireneusz Szpilewski


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk