用结构体变量的引用作函数参数


 1 #include <iostream>
 2 #include <string.h>
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 struct Student
 6 {
 7     int num;
 8     string name;
 9     float score[3];
10 }
11 stu={12345,"Li Li",88,89,98};
12 
13 int main(int argc, char** argv) {
14     void print(Student &);
15     print(stu);
16     return 0;
17 }
18 
19 void print(Student &stud)
20 {
21     cout <<stud.num<<" "<<stud.name<<" "<<stud.score[0]<<" "<<stud.score[1]<<" "
22     <<stud.score[2]<<endl;
23 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM