ch10_10.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:

C#编程

开发平台:

Visual C++

  1. //***********************
  2. //**    ch10_10.cpp    **
  3. //***********************
  4. #include <iostream.h>
  5. struct Person
  6. {
  7.   char name[20];
  8.   unsigned long id;
  9.   float salary;
  10. };
  11. void GetPerson(Person& p)    //结构参数引用传递的函数
  12. {
  13.   cout <<"Please enter a name for one person:n";
  14.   cin>>p.name;
  15.   cout <<"Please enter one's id number and his salary:n";
  16.   cin >>p.id >>p.salary;
  17. }
  18. void Print(Person& p)
  19. {
  20.   cout <<p.name <<"    "
  21.        <<p.id <<"    "
  22.        <<p.salary <<endl;
  23. }
  24. void main()
  25. {
  26.   Person employee[3];
  27.   for(int i=0; i<3; i++){
  28.     GetPerson(employee[i]);    //调用后,employee[i]被赋值
  29.     Print(employee[i]);
  30.   }
  31. }