|
Boost Users : |
From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-07-26 07:51:07
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Yossi.Itzkovich_at_[hidden]
> Sent: Wednesday, July 26, 2006 3:03 AM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] shared_ptr and inheritance of the raw pointer
>
> I have this code:
>
> #include <boost/shared_ptr.hpp>
>
> class A{ // base class
> public:
virtual ~A(); // otherwise A isn't polymorphic, can't downcast
> };
>
> class B : public A{
> public:
> int b1;
> };
>
> typedef boost::shared_ptr<A> tSmartA;
> typedef boost::shared_ptr<B> tSmartB;
>
> void foo (const tSmartB& smartOne); // need ; for syntax
^^^^^ permits passing an expression
>
> int main () {
> tSmartA a(new B);
foo(boost::dynamic_pointer_cast<B>(a));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> return 0;
> }
>
>
> How can I then send a to foo() ?
[Nat] With the three changed lines shown above, this compiles for me
under MSVC 7.1.
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