Boost logo

Boost :

From: ronenh_at_[hidden]
Date: 2000-03-16 09:38:41


Hi
I hope that this is the place to ask:-)
I'm using the shared_ptr and have two big problems.
I need help on this issues ASAP.

First problem:
==============

class A {
:
:
}
typedef shared_ptr<A> APtr;
typedef shaerd_ptr<const A> ConstAPtr;

How can I pass APtr object to method that get ConstAPtr.

In regular pointer this should work:
void func(const A a);
:
:
void main(){
   A a;
   func(a);
};

Second problem:
===============

How can I use Polymorphism with smart pointer.

For example:

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;
typedef shaerd_ptr<const Drive> ConstDrivePtr;

void Func(A *pA)
{
   pA->DoIt();
}
void SPFunc(APtr *pA)
{
   pA->DoIt();
}

void main()
{
   Drive d;
   Func(&d); // OK

   DrivePtr pD(&d);
   SPFunc(pD); // Not OK
};


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk