繁体   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