#include<iostream> using namespace std;
class People{ public: void getStature(){ cout <<"Zing的升高为:"<<stature<<"cm"<<endl; } void getWeight(); void setStature(int x){ stature = x; } void setWeight(int y); private: int stature = 0; int weight = 0; }; void People::getWeight(){ cout << "Zing的体重为:" << weight << "kg" << endl; } void People::setWeight(int y){ weight = y; } void main(){ People Zing; Zing.setStature(179); Zing.setWeight(60); Zing.getStature(); Zing.getWeight(); system("pause"); }
更多详情请点击 http://blog.sina.com.cn/zhaojianjunzjj