|
Boost : |
From: Ronen Halsadi (RonenH_at_[hidden])
Date: 2000-03-16 11:30:57
I'm using Microsoft VC++ version 6
> -----Original Message-----
> From: Valentin Bonnard [SMTP:Bonnard.V_at_[hidden]]
> Sent: ä 16 îøõ 2000 17:22
> To: boost_at_[hidden]
> Subject: [boost] Re: Questions
>
> ronenh_at_[hidden] wrote:
>
> > How can I pass APtr object to method that get ConstAPtr.
>
> Just do it.
>
> > How can I use Polymorphism with smart pointer.
>
> It should work.
>
> > class A {
> > :
> > virtual void DoIt();
> > :
> > };
> > typedef shared_ptr<A> APtr;
> > typedef shaerd_ptr<const A> ConstAPtr;
> >
> > class Drive : public A{
> > :
> > virtual void DoIt();
> > :
> > };
> > typedef shared_ptr<Drive> DrivePtr;
>
> > void main()
> ^^^^
> Hum hum
>
> > Drive d;
>
> > DrivePtr pD(&d);
> ^^
> Hum hum
>
> The following should compile:
>
> $ cat smart-ptr-const.cc
> #include "smart_ptr.h"
>
> using namespace boost;
>
> typedef shared_ptr<A> APtr;
> typedef shared_ptr<const A> ConstAPtr;
>
> void func (ConstAPtr) {}
>
> int main ()
> {
> APtr p;
> func (p);
> }
>
> (I get an ICE, but should not.)
>
> Anyway, the conversions won't work if your compiler
> doesn't support template member function.
>
> --
>
> Valentin Bonnard
>
> ------------------------------------------------------------------------
> You have a voice mail message waiting for you at iHello.com:
> http://click.egroups.com/1/2377/1/_/9351/_/953220118/
>
> -- Check out your group's private Chat room
> -- http://www.egroups.com/ChatPage?listName=boost&m=1
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk