wrote:
> I know this is a bit of a digression from the OP's question but
> shouldn't there be a delete Bottom; to avoid a memory leak? (I'm not
> completely sure -- this is a genuine question, not a rhetorical one.)
>
> Paul Epstein
In my opinion, yes and no. Yes, the memory needs to be deleted, but no,
not by delete. Here would be my main:
int main()
{
boost::shared_ptr<Right> right(boost::shared_ptr<Bottom>(new
Bottom()));
cout << "right->a: " << right->a << endl;
return 0;
}
The shared_ptr cleans up for you when it goes out of scope.
Todd Gardner