C++訪問類的私有數據成員的三種方法

老是忘記C++的私有數據成員到底什麼能訪問,今天總結下,特此記錄。 注:還可使用指針訪問修改private數據成員的值:web class Test { private: int x; int y; public: explicit Test(int _x,int _y) :x(_x),y(_y) {} void Pintf() { cout << x <<" "<<y<<endl; }
相關文章
相關標籤/搜索