我有一个全局函数void start_menu()
,我将其用作界面。
void start_menu()
{
int x;
cout << " ------------------------------------" << endl;
cout << " WELCOME TO LIBRARY MANAGEMENT SYSTEM" << endl;
cout << "------------------------------------" << endl;
cout << " 1. ABOUT Books " << endl;
cout << " 2. ABOUT Members " << endl;
cout << " CHOOSE:";
cin >> x;
Books MyBooks; //object of books class
do
{
if (x==1)
{
system("cls");
MyBooks.INTR_Books(); //calling function of Books Class
}
};
}
然后,我想要在全局函数class Books{}
中调用void start_menu()
,但是当我创建一个Books
类的对象时,它被定义为Books MyBooks;
,上面的代码给了我这个错误:
错误:&#39;图书&#39;未在此范围内宣布。
这是全局函数Books
之后的void start_menu()
类:
class Books
{
public:
string BookName; //name of the Book
string Auth; //Author of the book
string Trans; // translator of the book
string myArray[20];
int BookCode; // code of the book
int BookNum; // number of copies exist
void INTR_Books(); //show interface related to books
void ADD_BOOK();
void DELETE_BOOK();
void SEARCH();
void SHOW_ALL();
void BR_BOOK();
};
答案 0 :(得分:0)
基于评论,我在Books
全局函数之后应该调用void start_menu()
类,这是不可能的。