template<typename T>
class SmartPtr
{
T* m_p;
public:
SmartPtr(T* p) : m_p(p)
{}
T* operator->()
{
return m_p;
}
}
class XxX
{
public:
void foo();
}
int main()
{
Xxx x;
SmartPtr<XxX> sp(&x);
sp->foo(); // ok
}