用指向结构体变量的指针作实参
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 Fung",99,87,78}; 12 13 int main(int argc, char** argv) { 14 void print(Student *); 15 Student *pt=&stu; 16 print(pt); 17 return 0; 18 } 19 20 void print(Student *p) 21 { 22 cout <<p->name<<" "<<p->num<<" "<<p->score[0]<<" " 23 <<p->score[1]<<" "<<p->score[2]<<endl; 24 }