?把struct结构体改成calss类
#include <iostream>
class u
{
public:
int score;
private:
int age;
char sex;
float high;
public:
void set_msg(int a,char sex,float high);
int get_age();
char get_sex();
float get_high();
};
using namespace std;
void u::set_msg(int a,char s,float h)
{
age=a;
sex=s;
high=h;
}
int u::get_age()
{
return age;
}
char u::get_sex()
{
return sex;
}
float u::get_high()
{
return high;
}
int main()
{
u s;
s.set_msg(18,'w',93.14);
cout << "age:" <<s.get_age() << endl;
cout << "sex:" <<s.get_sex() << endl;
cout << "high:" << s.get_high() << endl;
return 0;
}
写一个有默认参数的函数,把声明和定义分开,并在主函数内成功调用