<分区>
我正在尝试使用 C++ 和 SDL 编写游戏,但我遇到了一个问题。 我有一个 Bat 类和一个 Game 类。 当我尝试创建一个 bat 对象并调用构造函数时,出现以下错误:
"error: expected identifier before numeric constant"
这里是源文件:
游戏.h
#ifndef GAME_H
#define GAME_H
#include "SDL.h"
#include "Bat.h"
class Game
{
public:
Game();
Bat bat(0, 0);
private:
};
#endif // GAME_H
Bat.h
#ifndef BAT_H
#define BAT_H
class Bat
{
public:
Bat(int x, int y);
int getX() {return x;}
int getY() {return y;}
private:
int x, y;
};
#endif // BAT_H
Bat.cpp
#include "Bat.h"
Bat::Bat(int x, int y)
{
}