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:
deli.cc:10:7: error: expected unqualified-id before ‘[’ token int [] myCashierNums; ^ deli.cc:11:7: error: expected unqualified-id before ‘[’ token int [] myOrderNums; ^
Here's the program I compiled using g++ on Ubuntu 14.04 64-bit.
#include <iostream>
#include <stdlib.h>
using namespace std;
class SandwichBoard {
//private:
int myMaxOrders;
int [] myCashierNums;
int [] myOrderNums;
//public:
SandwichBoard (int maxOrders) {
myMaxOrders = maxOrders;
myCashierNums = new int [maxOrders];
myOrderNums = new int [maxOrders];
// All values initialized to -1
for (int i = 0; i < maxOrders; i++){
myCashierNums[i] = -1;
myOrderNums[i] = -1;
}
}
// For debugging purposes
void printMyOrders() {
for (int i = 0; i < maxOrders; i++){
cout << "Cashier " << myCashierNums[i] << ", ";
cout << "Order " << myOrderNums[i] << endl;
}
}
int getMaxOrders () { return myMaxOrders; }
};
void cashier(void *in) {
}
void sandwich_maker(void *in) {
}
int main(int argc, char *argv[]) {
}
This is C++, not Java! Declare arrays like this:
Please note that the arrays in C++ must have a size at compile time. In the above example, it is 1000.
modify:
add: