2016-12-02 4 views
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; 
    } 
    } 
} 

答えて

1

いいえ、実際には一致しません。

showInfo()の2番目のパラメータは、可変整数の参照です。

constという参照番号をconst int SIZEに渡そうとしています。

showInfoの2番目のパラメータをconst int &に変更します。実際にはそれを平文にするかもしれませんint、実際に。私はここでの参照をどのように渡して有用なものを達成するのか分かりません。

+0

これにより、エラーが「タイプ名が許可されていません」 – Nick5227

+0

に変更されました。間違っているはずです。別の質問を投稿して、コードの新しいバージョンを表示してください。 –

+0

オリジナルの投稿を更新します。繰り返しの質問でstackoverflowを利用したくありません! – Nick5227

関連する問題