#include <iostream> using namespace std; class CT{ int x; public: const int& X; CT():X(x){} void setx(int n){x=n;} }; int main() { CT obj; obj.setx(4); //obj.X=3; //const成员不可改变 //obj.x=3; //private成员不可见 //cout<<obj.x<<endl; //private成员不可见 cout<<obj.X<<endl; system("pause"); }