2012年10月5日 星期五

C++學習筆記(2)-雙冒號的使用

:: 雙冒號可以使用在...

1.定義某一class內method的實作
    ex1:
    class ex{
      public:
        int testValue;
        int test1(int a);
    };

    int ex::test1(int a){
       return a;
    }

2.也可以用來讀取class內的變數值
    ex2:
    承ex1...
    int ex::test1(int a){
      return a + ::testValue;
    }

沒有留言:

張貼留言