我收到错误“必须调用对非静态成员函数的引用”,但是如果我按照我的书所说的那样调用它:
Mammal myMammal;
myMammal.mammals[i].printExhibitForAnimals
它说“在哺乳动物中没有一个名叫'哺乳动物'的成员”
void printExhibit(Mammal mammals[], Personnel personnel[],
string exhibitToFind, int numMammals, int numPersonnel)
{
int combo = numMammals + numPersonnel;
for (int i = 0; i < combo; i++){
mammals[i].printExhibitForMammals;
personnel[i].printExhibitForPersonnel;
}
}
头文件的相关部分:
struct Mammal {
std::string species;
Date birthDate;
int weight;
SizeOfEnclosure sizeofenclosure;
std::string exhibitName;
Mammal();
void getMammalsData(std::ifstream& inFile);
void displayMammals(Mammal mammals[], int totalMammals);
void printExhibitForMammals(Mammal mammals[],std::string
exhibitNameToFind, int numMammals);
};
答案 0 :(得分:0)
我认为这里有两个问题。