このエラーを修正するために何度も試みましたが、どうすればよいかわかりません。addBooks 関数と displayBooks 関数の両方で、「関数は引数を 1 つ取りません」というエラーが表示されますが、ベクトルは 1 つの引数である必要があります。
struct bookStruct
{
char title[40];
char author[40];
int pages;
int year;
};
enum menu { display=1, add, end} ;
void displayOptions();
void displayBooks();
void addBooks();
int main(){
vector<bookStruct> book(1);
string option = "display";
displayOptions();
cin >> option;
//std::strcpy(book[0].title, "a");
//std::strcpy(book[0].author, "a");
//book[0].pages = 0;
//book[0].year = 0;
while (option != "end"){
addBooks(book);
displayBooks(book);
}
return 0;
}
void displayOptions(){
cout << "1. Display list of books" << endl;
cout << "2. Add books" << endl;
cout << "3. Exit" << endl;
}
void displayBooks(vector<bookStruct> book){
for (int n = 0; n<book.size(); n++){
cout << book[n].title << " ; " << book[n].author << " ; "
<< book[n].pages << " ; " << book[n].year <<endl;
}
cout << endl;
}
void addBooks(vector<bookStruct> book){
int n = book.size()+1;
book.resize(book.size()+1);
cout << "Enter the book title: " << endl;
cin >> book[n].title;
cout << "Enter the author name: " << endl;
cin >> book[n].author;
cout << "Enter the number of pages: " << endl;
cin >> book[n].pages;
cout << "Enter the publication year: " << endl;
cin >> book[n].year;
}