Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在c+中调用全局函数中的类对象+;?_C++_Object - Fatal编程技术网

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(); 
};