C++ 如何在c+中调用全局函数中的类对象+;?
我有一个全局函数C++ 如何在c+中调用全局函数中的类对象+;?,c++,object,C++,Object,我有一个全局函数void start\u menu(),我正在使用它作为接口 void start_menu() { int x; cout << " ------------------------------------" << endl; cout << " WELCOME TO LIBRARY MANAGEMENT SYSTEM" << endl; cout << "--------------
void start\u 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
}
};
}
根据评论,我有一个undrestood,它应该在
void start\u menu()
global函数之后调用Books
类。是在函数之前还是之后声明的?@NathanOliver,它还需要定义。@uncomputable True,但这可以是后者,也可以是另一个文件function@moh89,将其拉到功能上方。
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();
};