在C++中类
#include<iostream.h> class humn{ public: void get_hight(){ cout<<hight; } void get_weight(); void set_hight(int x){ hight = x; } void set_weight(int y); private: int hight; int weight; }; void humn::get_weight(){ cout<<weight; } void humn::set_weight(int y){ weight = y; } int main() { humn mike; mike.set_hight(2); mike.set_weight(180); mike.get_hight(); mike.get_weight(); return 0; }
时间: 2024-10-26 04:03:00