【发布时间】:2015-10-01 05:39:06
【问题描述】:
所以我对类编程有点陌生,我不确定我的代码做错了什么,因为我试图打印一个二维数组,但在尝试构建它时出现错误。这里是:
#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;
}
构建时出现的错误是:
'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]
【问题讨论】: