小编Bor*_*nko的帖子

将结构传递给void函数

我的问题是如何将struct.variable(或结构数组)传递给void函数.基本上代码如下:

结构

struct Person{
    string surname;
    string BType;
    string organ;
    int age;
    int year, ID, IDp;
} Patient[50], Donor[50];

int i; // counter variables for the arrays such as Patient[i].BType... etc
int i1; 
Run Code Online (Sandbox Code Playgroud)

那么函数的代码是这样的一行:

void compare(int &i, int &i1, Person &Patient[50], Person &Donor[50]);
Run Code Online (Sandbox Code Playgroud)

我试图通过i,i1,PatientDonor结构.为什么这不起作用?有没有一种特殊的方法将这些结构传递给函数?

变量结构中的值也是从文件中读取的(不要认为这会改变任何内容).有任何想法吗?

c++ file-io struct pass-by-reference void

1
推荐指数
1
解决办法
2136
查看次数

标签 统计

c++ ×1

file-io ×1

pass-by-reference ×1

struct ×1

void ×1