其他文件中的结构矢量和函数

时间:2019-04-07 02:04:21

标签: c++ vector struct

在我的程序中,我有一个包含主要功能的文件,另一个包含其他功能的文件。我有一个结构并创建了一个向量:

struct Animal {
    string name;
    string type;
    string regestration;
    int problem;
};
vector<Animal> animals;

在其他功能的头文件中,我具有以下内容:

void loadAnimals(string &file, vector<Animal> animals);

编译时出现错误:'Animal' was not declared in this scope 以上行。

我是否需要在头文件中再次声明该结构?还是我使用的语法错误

0 个答案:

没有答案