我正在为一个使用基本Windows控制台的游戏制作一个屏幕。
不幸的是,我收到了这个错误
1>d:\users\chris\documents\programs\testing\roguelike mkii\roguelike mkii\screen.h(49): error C2143: syntax error : missing ';' before '['
1>d:\users\chris\documents\programs\testing\roguelike mkii\roguelike mkii\screen.h(49): error C2337: 'pPoint' : attribute not found
1>d:\users\chris\documents\programs\testing\roguelike mkii\roguelike mkii\screen.h(49): error C2143: syntax error : missing ']' before '.'
1>d:\users\chris\documents\programs\testing\roguelike mkii\roguelike mkii\screen.h(49): error C2143: syntax error : missing ';' before '.'我似乎无法摆脱它。
同样在setChar()函数中,pPoint.nX说它必须是常量,我无法理解。
struct pointOnScreen
{
char character;
int colour;
};
class Screen
{
private:
const int xLength;
const int yLength;
pointOnScreen** screen;
public:
Screen() : xLength(80), yLength(24)
{
screen = new pointOnScreen*[xLength];
for(int ix = 0; ix < xLength; ix++)
{
screen[ix] = new pointOnScreen[yLength];
for(int iy = 0; iy < yLength; iy++)
{
screen[ix][iy].character = ' ';
screen[ix][iy].colour = 0;
}
}
}
~Screen()
{
for(int i = 0; i < xLength; i++)
{
delete[] screen[i];
}
delete[] screen;
}
void setChar(char toSet, point pPoint)
{
pointOnScreen[pPoint.nX][pPoint.nY] = toSet;
}
};非常感谢您的帮助。
发布于 2014-11-08 22:45:41
pointOnScreenpPoint.nX = toSet;
pointOnScreen是一种类型,而不是variable。
我猜你是说:
screen[pPoint.nX][pPoint.nY] = toSet;https://stackoverflow.com/questions/26822851
复制相似问题