#include <iostream>
using namespace std;
int add(int a=1,int b=1);//有默认参数的情况下,函数声明写默认参数,定义不写
int add(int a,int b)
{
return a+b;
}
class STU
{
private:
int score;
float height;
public:
string name;
bool gender;
int get_score();
float get_height();
void set(string n,bool g,int s,float h);
};
int STU::get_score()
{
return score;
}
float STU::get_height()
{
return height;
}
void STU::set(string n,bool g,int s,float h)
{
name=n;
gender=g;
score=s;
height=h;
}
int main()
{
STU s1;
s1.set("傻逼",1,59,1.45);
cout<<s1.name<<endl;
cout<<s1.gender<<endl;
cout<<s1.get_score()<<endl;
cout<<s1.get_height()<<endl;
cout<<add()<<endl;
return 0;
}
12、27
于 2023-12-27 20:58:10 首次发布