So I am somewhat new to programming in classes, and I am unsure what I'm doing wrong with my code, as I am trying to print a 2 dimensional array but an error comes up when trying to build it. Here it is:
#include <iostream>
using namespace std;
class PlaneSeats
{
private:
char seatAvailability[7][4];
public:
PlaneSeats();
void displayAvailability();
};
PlaneSeats::PlaneSeats()
{
seatAvailability[7][4] = {{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'},
{'A', 'B', 'C', 'D'}};
}
void PlaneSeats::displayAvailability()
{
cout << row+1 << " ";
for (int column = 0; column<4; column++)
{
cout << seatAvailability[row][column] << " ";
}
cout << endl;
}
int main()
{
PlaneSeats plane;
plane.displayAvailability();
return 0;
}
The errors that come up when building are:
'row' was not declared in this scope line 27
Symbol 'row' could not be resolved line 27
Symbol 'row' could not be resolved line 30
Multiple markers at this line line 22
- cannot convert '<brace-enclosed initializer list>' to 'char' in assignment
- extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by
default]