??????????????C++дC??????????C++дC????????????????????????????е????????????public?????????????????????public??private?????????????~~~
????#define??
????1.?????public??????????????????е?????????????????г?????????
????2.?????private??????????????????е????????????????????
?????????????????????г??????????????????????????????????????
class Cat
{
public:
int weight;
};
int main()
{
Cat cat;//???????????
cat.weight=5;
cout<<"The cat's weight is "<<cat.weight<<endl;
return 0;
}
??????????????????У?????Cat???е???????weight????????????г??????????????????????????????????Cat??????cat??????????.???????????????weight????????????
???????????????????????????????????????е?public?????????private??????????????????????Cat??????????????е??????weight??????????????????????????????????????????????????weight??????????????
class Cat
{
public:
void setWeight(int w){weight=w;}//????????
int print(){return weight;}//???????????С
private:
int weight;
};
int main()
{
Cat cat;
cat.setWeight(5);//????cat???????5
cout<<"The cat's weight is "<<cat.print()<<endl;
return 0;
}