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
}

posted on 2008-03-26 22:02  悠然小调  阅读(505)  评论(0编辑  收藏  举报