Stroustup の本の 368 ページから抽出されたこのコード スニペットにはタイプミスがあると思います。
template <class X> class std::auto_ptr
{
template <class Y> struct auto_ptr_ref { /* ... */ }; // helper class
X * ptr;
public :
typedef X element_type;
explicit auto_ptr(X* p =0) throw() { ptr = 0; }
auto_ptr (auto_ptr& a) throw() { ptr = a.ptr; a.ptr = 0; } // note: not const auto_ptr&
/* ... */
};
すべきではない
explicit auto_ptr(X* p =0) throw() { ptr = 0; }
なれ
explicit auto_ptr(X* p =0) throw() { ptr = p; }
代わりは ?