|
Boost Users : |
From: rz0 (rz0_at_[hidden])
Date: 2001-12-08 21:56:31
Hello
I have the following scenario:
#include <iostream>
#include <boost/smart_ptr.hpp>
class A
{
public:
virtual void func1() { std::cout << "A::func1" << std::endl; }
};
class B : public A
{
public:
void func1() { std::cout << "B::func1" << std::endl; }
void funcB() { std::cout << "B::funcB" << std::endl; }
};
class C : public A
{
public:
void func1() { std::cout << "C::func1" << std::endl; }
void funcC() { std::cout << "C::funcB" << std::endl; }
};
class Holder
{
boost::shared_ptr<A> aptr;
public:
void setclass(boost::shared_ptr<A> a) { aptr = a; }
void callfunc() { aptr->func1(); }
};
int main()
{
Holder holder;
boost::shared_ptr<B> b(new B());
boost::shared_ptr<C> c(new C());
holder.setclass(b); //<-------
holder.setclass(c); //<-------
holder.callfunc();
return 0;
}
VC++ 6.0 flags the above lines with a conversion error.
Is there any way to resolve this?
Thanks very much in advance.
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