0
我對這個錯誤的理解是原型和頭文件中的參數與頭文件中的參數不匹配,但是在我的代碼中這些東西匹配。我不確定我在這裏錯過了什麼?錯誤「showInfo(info,SIZE);」「沒有過載函數的實例」
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const int SIZE = 3;
int main();
void showInfo(Author info[], const int &);
struct BookInfo
{
string title;
double price;
};
struct Author
{
string name;
BookInfo books[SIZE];
};
int main()
{
Author info[] = { {"NONE", {{"NONE", 0.00}, {"NONE", 0.00}, {"NONE", 0.00}}},
{"NONE", {{"NONE", 0.00}, {"NONE", 0.00}, {"NONE", 0.00}}},
{"NONE", {{"NONE", 0.00}, {"NONE", 0.00}, {"NONE", 0.00}}},
};
showInfo(info,SIZE);
return 0;
}
void showInfo(Author info[], const int&)
{
for (int i = 0; i < SIZE; i++)
{
cout << info[i].name << endl;
for (int j = 0; j < SIZE; j++)
{
cout << info[i].books[j].title << endl;
cout << info[i].books[j].price << endl;
}
}
}
這將錯誤更改爲「類型名稱不允許」 – Nick5227
您必須犯了一個錯誤。隨意發佈另一個問題,顯示您的代碼的新版本。 –
我會更新我原來的帖子,不想再重複提問帶上stackoverflow! – Nick5227