123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #include <iostream>
- #if(0)
- struct Student
- {
-
- std::string name;
-
- int age;
-
- int score;
- };
- void printStudent1(struct Student s)
- {
- s.age = 100;
- std::cout << "子函数1中 姓名:" << s.name << "年龄:" << s.age << "分数:" << s.score << std::endl;
- }
- void printStudent2(struct Student *p)
- {
- p->age = 200;
- std::cout << "子函数2中 姓名" << p->name << "年龄:" << p->age << "分数:" << p->score << std::endl;
- }
- int main()
- {
-
-
- struct Student s;
- s.name = "张三";
- s.age = 20;
- s.score = 85;
-
- printStudent2(&s);
-
- std::cout << "main函数中打印 姓名:" << s.name << "年龄:" << s.age << "分数:" << s.score << std::endl;
- system("pause");
- return 0;
- }
- #endif
|