C++: auto_ptr + forward declaration?
问题 I have a class like this: class Inner; class Cont { public: Cont(); virtual ~Cont(); private: Inner* m_inner; }; in the .cpp, the constructor creates an instance of Inner with new and the destructor delete s it. This is working pretty well. Now I want to change this code to use auto_ptr so I write: class Inner; class Cont { public: Cont(); virtual ~Cont(); private: std::auto_ptr<Inner> m_inner; }; Now, the constructor initialized the auto_ptr and the destructor does nothing. But it doesn't