我收到了这个错误:
Expected '(' for function-style cast or type construction
在第二行:
struct OpenALInterface * CreateOpenALInterface(int numLoadedSounds, int numPlayingSounds){
return new IOS_OpenAL(int numLoadedSounds, int numPlayingSounds); //ERROR ABOVE
// return new IOS_OpenAL(); //this works fine, no error
};
班级有这个:
class IOS_OpenAL: public OpenALInterface{
public:
IOS_OpenAL(int numLoadedSounds, int numPlayingSounds){
//do stuff
};
// IOS_OpenAL(){}; //works
这个错误究竟是指什么?它看起来像语法错误。
基类是抽象的,没有构造函数。这是问题吗?子类是否可以覆盖或拥有不在基类中的自己的构造函数?
答案 0 :(得分:3)
return new IOS_OpenAL(int numLoadedSounds, int numPlayingSounds);
应该是
return new IOS_OpenAL(numLoadedSounds, numPlayingSounds);
发生错误是因为编译器看到那些“int”标记并且认为你正在尝试将某些内容转换为int,但你不是。
答案 1 :(得分:3)
你的意思是:
struct OpenALInterface * CreateOpenALInterface(int numLoadedSounds, int numPlayingSounds){
return new IOS_OpenAL(numLoadedSounds, numPlayingSounds);
};