Boost logo

Boost Users :

From: Hughes, James (jhughes_at_[hidden])
Date: 2007-05-01 10:51:01


I should have been a bit more specific - let's say that the DoStuff
functions in B are in addition to any virtual functions there may be in
A (which make it polymorphic and were omitted in the example). This is
why I do need to be able to call specific functions in B, but still need
to stored or passed to functions as the base class pointer A. Hence the
issue.

James

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Jules
d'Entremont
Sent: 01 May 2007 15:27
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [Shared_ptrs] As I doing this right

> 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 mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

This message (including any attachments) contains confidential
and/or proprietary information intended only for the addressee.
Any unauthorized disclosure, copying, distribution or reliance on
the contents of this information is strictly prohibited and may
constitute a violation of law. If you are not the intended
recipient, please notify the sender immediately by responding to
this e-mail, and delete the message from your system. If you
have any questions about this e-mail please notify the sender
immediately.


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