所以我创建这个类包含一个字符串,类处理创建精灵设置他们的图标等等,但我遇到了一个错误。字符串常量之前的预期标识符C++错误
下面是类代码:
class staticmob{
public:
sf::Sprite icon;
sf::Texture iconTexture;
std::string object_name;
bool density = false;
staticmob(sf::Sprite mIcon,
std::string mName,
std::string fileName,
const bool dense,
bool inObjList,
turf *object_list);
};
错误所在:
staticmob midGround(sf::Sprite midGround,
"Ground",
"tileset.png",
true,
true,
background);
错误:
error: expected identifier before string constant
error: expected ',' or '...' before string constant
任何的帮助深表感谢(是的,我略低在C++新手,但我得到的窍门它)
什么是'midGround'咋办至 是?你在两个变量声明中使用了它的名字? – 2014-09-18 21:45:48
通过const引用传递非基本类型以避免副本。 – 2014-09-18 23:39:23