Boost logo

Boost Users :

From: Jules d'Entremont (Jules.dEntremont_at_[hidden])
Date: 2007-05-01 10:26:42


> From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of
> Hughes, James
> Sent: May 1, 2007 5:19 AM
> To: Boost-users_at_[hidden]
> Subject: [Boost-users] [Shared_ptrs] As I doing this right
>
> Although I have been using shared_ptr's for a while, I still get a bit
> confused with polymorphic stuff ...no change there.
>
> An pseudocode example:
>
> Class A
> {
> };
>
> Class B : public A
> {
> DoStuff1();
> DoStuff2();
> DoStuff3();
> DoStuff4()
> };

This is not polymorphic. To make this example polymorphic you need to
declare the functions virtual in class A.

> So, the quesiton is one of efficiency - if I was using pointers, I
would
> just new a B and assign to a B* variable, then pass in to the function
> which would use it as an A - no temp required.

This requires that the functions be declared in A. If you do that, your
example will work with either raw pointers or shared_ptr's.

Jules.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net