#include<iostream>
using namespace std;
template<class T>
class auto_ptr1
{
public:
explicit auto_ptr1(T* p =0 ):pointee(p){ cout<<"p..\n";}
template<class U>
auto_ptr1(auto_ptr1<U>&rhs):pointee(rhs.release()){cout<<"rhs..\n";}
~auto_ptr1()
{
cout<<"~\n";
delete pointee;
}
template<class U>
auto_ptr1<T>& operator=(auto_ptr1<U>&rhs)
{
cout<<"=\n";
if(this != &rhs)
reset(rhs.release());
return *this;
}
T& operator*()const
{
cout<<"*\n";
return *pointee;
}
T* operator->()const
{
cout<<"->\n";
return pointee;
}
T* get()const
{
return pointee;
}
//...
private:
T* pointee;
};
void test()
{
auto_ptr1<string> ps (new string("jjhou"));
cout<<*ps<<endl;
cout<<ps->size()<<endl;
}
int main()
{
test();
}