1

我收到此错误:

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

这个错误到底指的是什么?它看起来像一个语法错误。

基类是抽象的,没有构造函数。是这个问题吗?子类可以覆盖或拥有自己的构造函数不在基类中吗?

4

2 回答 2

3
return new IOS_OpenAL(int numLoadedSounds, int numPlayingSounds);

应该

return new IOS_OpenAL(numLoadedSounds, numPlayingSounds);

发生错误是因为编译器看到那些“int”标记并认为您正在尝试将某些内容强制转换为 int,但您没有。

于 2013-01-23T06:42:45.087 回答
3

你是不是这个意思:

struct OpenALInterface * CreateOpenALInterface(int numLoadedSounds, int numPlayingSounds){
   return new IOS_OpenAL(numLoadedSounds, numPlayingSounds);
};
于 2013-01-23T06:43:15.843 回答