#include <iostream>
using namespace std;
struct student {
string name;
int age;
int score;
};
//函数
//1.值传递
void printStu1(struct student h) {
cout << "姓名:" << h.name << "年龄:" << h.age << "分数:" << h.score << endl;
}
//2.地址传递
void printStu2(struct student* h) {
cout << "姓名:" << h->name << "年龄:" << h->age << "分数:" << h->score << endl;
}
int main() {
struct student s;
s.name = "王五";
s.age = 18;
s.score = 99;
printStu1(s);
printStu2(&s);
system("pause");
return 0;
}
C++-结构体做函数参数
最新推荐文章于 2024-10-06 21:16:16 发布
758

被折叠的 条评论
为什么被折叠?



