Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - problem with boost::shared_ptr<abstract>(concretederived)
Example code from http://www.boost.org/libs/smart_ptr/sp_techniques.html ST: "Using abstract classes for implementation hiding" //--------------------------- X.hpp: class X { public: virtual void f() = 0; virtual void g() = 0; protected: ~X() {} }; shared_ptr<X> createX(); //-------------------------- X.cpp: class X_impl: public X { private: X_impl(X_impl const &); X_impl & operator=(X_impl const &); public: virtual void f() { // ... } virtual void g() { // ... } }; shared_ptr<X> createX() { shared_ptr<X> px(new X_impl); return px; } //------------------------------ Doesn't compile in DM, 8.38; says that it cannot create abstract class. Even if I say... shared_ptr<X> createX() { shared_ptr<X_impl> px(new X_impl); return static_cast< shared_ptr<X> >(px); } I still get the same message. dan Dec 23 2003
Update: If I leave the pure virutal functions...//--------------------------- X.hpp: class X { public: virtual void f() = 0; virtual void g() = 0; protected: ~X() {} }; Dec 23 2003
|