营销网站费用,小内存安装wordpress,谷歌优化培训,内江网站开发0832hdsj1.定义一个学生的结构体#xff0c;包含学生的姓名#xff0c;年龄#xff0c;成绩#xff0c;性别#xff0c;学生的成绩#xff0c;姓名#xff0c;定义为私有权限#xff1b;定义一个学生类型的结构体变量#xff0c;设置公有函数用于给学生的成绩和名字进行赋值包含学生的姓名年龄成绩性别学生的成绩姓名定义为私有权限定义一个学生类型的结构体变量设置公有函数用于给学生的成绩和名字进行赋值(结构体中的函数结构体中声明结构体外定义)
#include iostreamusing namespace std;struct stu
{int age;string sex;void func();void set_name(string str,float s){name str;score s;}
private:string name;float score;
};
void stu::func()
{cout name endl;cout age endl;cout sex endl;cout score endl;
}
int main()
{stu students;string str xjx;students.age 22;students.sex 女;float s 100;students.set_name(str,s);students.func();return 0;
}