#include <memory>
class X
{
public:
virtual void f() = 0;
virtual void g() = 0;
virtual ~X() { printf("~X\n");}
};
class X_impl: public X
{
private:
X_impl(){};
public:
~X_impl()
{
printf("~X_impl\n");
};
virtual void f()
{
printf("X_impl.f()\n");
}
virtual void g()
{
printf("X_impl.g()\n");
}
private:
friend std::auto_ptr<X> createX();
};
std::auto_ptr<X> createX()
{
std::auto_ptr<X> px(new X_impl);
return px;
}