抱歉,小弟底子實在是太差了
不把 template 和 operator 的 overload 搞定根本很難看 android 的 code...
#include<iostream>
#include<stdlib.h>
using namespace std;
template<typename T>
class Demo{
          public:
                      inline Demo():m_ptr(0){
                             cout<<"This is the First constructor "<<endl;
                      }
                        Demo(T* other);
                        Demo(const Demo<T>& other);
                        //Assigment
                            Demo& operator = (T* other);
                        //Accessors
                        inline  T*    operator-> () const { return m_ptr;  }
                        inline  T&    operator* () const  { return *m_ptr; }
          private:
                        T* m_ptr;
};
template<typename T>
Demo<T>::Demo(T* other){
        cout<<"This is the Second constructor"<<endl;
}
template<typename T>
Demo<T>::Demo(const Demo<T>& other){
        cout<<"This is the Thirdth constructor"<<endl;
}
class myClass{
        public:
                        myClass();
};
int main(){
    Demo<myClass> d;
    myClass *mptr = 0;
    //我該如何使用 Demo 類別的 Assigment 和 Accessors 呢?
    cout << *d <<endl; //error
    d = *mptr; //error
    d.operator*(mptr); //error
}
感謝指教...