簡體   English   中英

Turbo C++ 程序中的語法錯誤

[英]Syntax error in a turbo c++ program

我的代碼中出現聲明語法錯誤,但我沒有發現任何錯誤輸入或任何內容。請幫助。我正在使用 turbo c++ 進行我的學校級編程。 我在輸入 -void issue() 的地方得到它(在主函數內)

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>

class book {
    char bookname[20];
    char isbn[20];
    char author[20];
    char category[20];
    float price;
    int noc;

  public:

    void accept(){
        cout<<"Enter book name :- \n";
        gets(bookname);
        cout<<"Enter isbn no of the book:- \n";
        gets(isbn);
        cout<<"Enter authour name:- \n";
        gets(author);
        cout<<"Enter category of book:- \n";
        gets(category);
        cout<<"Enter price of the book :- \n";
        cin>>price;
        cout<<"Enter no of copies of book available in the library :- \n";
        cin>>noc;
    }

    void display() {
        cout<<"Name of the book is :- ";puts(bookname);cout<<endl;
        cout<<"ISBN :- ";puts(isbn);cout<<endl;
        cout<<"Author :- ";puts(author);cout<<endl;
        cout<<"Category :- ";puts(category);cout<<endl;
        cout<<"Price :- ";cout<<price<<endl;
        cout<<"No of copies available :- ";cout<<noc<<endl;
    }

    void issue();

}b[5];


int main() {
    for(int i=0;i<5;++i) {
        b[i].accept();
    }

    void issue() {
        int flag=1;
        char booksearch[20];
        cout<<"Enter name of book member wants to issue :- \n";
        gets(booksearch);
        for(int i=0;i<5;++i) {
            flag=strcmp(booksearch,b[i].bookname);
            if(flag==0)
                break;
        }

        if(flag==0) {
            cout<<"Book found \n";
            b[i].display();
            b[i].issue();
        } else {
            cout<<"Book not available:- \n";
        }

    }

    getch();
    return 0;
}
  1. main沒有右大括號 在void issue()之前放入一個
  2. 現在將void issue()更改為void book::issue()

解決這個問題然后告訴我們任何進一步的錯誤以及它發生的行

編輯

而不是 1) 移動

  getch();
  return 0;
}

到那個位置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM