学习c++:获得函数私有变量

#include "stdafx.h"
#include "iostream"
using  namespace std;
class C{

public:
 int  GetX(){return X;}
 void SetX(int X){this->X = X;}
private:
 int X;
};

void main(){
 C c;
 cout<<c.GetX()<<endl;
 cin.get();
 c.SetX(111);
 cout<<c.GetX()<<endl;
 cin.get();
 
}

大部分转载 小部分自写
原文地址:https://www.cnblogs.com/8586/p/1255690.html