Expected unqualified-id before '[' token

后端 未结 2 1573

I know this error is generally for syntax errors, but I can\'t seem to find anything wrong with this code. Can anyone help me point it out? Here are the errors I\'m getting:

相关标签:
2条回答
  • This is C++, not Java! Declare arrays like this:

    int myCashierNums[1000];
    int myOrderNums[1000];
    

    Please note that the arrays in C++ must have a size at compile time. In the above example, it is 1000.

    0 讨论(0)
  • 2021-02-14 05:44

    modify:

    int myMaxOrders;
    int* myCashierNums;
    int* myOrderNums;
    

    add:

    ~SandwichBoard() {
        if (myMaxOrders) {
           delete [] myCashierNums;
           delete [] myOrderNums;
        }
    }
    
    0 讨论(0)
提交回复
热议问题