【发布时间】:2014-03-29 04:12:05
【问题描述】:
我正在尝试实现 Marmalade 的 IwBilling (c++),但我得到的只是错误:“必须调用对非静态成员函数的引用”。 我使用以下代码:
=== [ main cpp file ] ===
#include <s3e.h>
#include "MyGame.h"
int main () {
IwGxInit();
{
MyGame game = new MyGame();
}
IwGxTerminate();
}
=== [ MyGame.h ] ===
#include "IwBilling.h"
class MyGame{
void billingError( void* caller, IwBilling::CIwBillingErrorData* data ) {}
MyGame() {
if ( IwBilling::isAvailable() && IwBilling::Init() ) {
IwBilling::setErrorCallback( billingError ); // !!! ERROR: Reference to non-static member function must be called
}
}
};
这里有什么问题?为什么会这样?如果我写:“static void billingError”一切正常。但我不知道在 void billingError 之前使用 static 是否正确?
我不明白为什么我的 MyGame() 构造函数是静态方法?我怎样才能做到非静态?
【问题讨论】:
-
setErrorCallback 的声明在哪里?
-
它在 IwBilling 类中。这不是我的课,所以我不能改变它。这是一个名为 Marmalade 的 SDK。
标签: c++ constructor static