die Funktion nimmt kein 1-Argumente-Fehler

Habe ich schon oft versucht diesen Fehler zu beheben aber ich bin mir nicht sicher, was zu tun ist. Sowohl die addBooks und displayBooks Funktionen bin ich immer eine "Funktion nimmt kein 1-Argumente" - Fehler, wenn der Vektor nur mit einem argument.

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;
}
  • Ihre Funktion Prototypen nicht mit den Implementierungen.
InformationsquelleAutor user2105982 | 2013-04-04
Schreibe einen Kommentar