Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 意外调用copyWithZone c++;cocos2d_C++_Cocos2d Iphone_Copywithzone - Fatal编程技术网

C++ 意外调用copyWithZone c++;cocos2d

C++ 意外调用copyWithZone c++;cocos2d,c++,cocos2d-iphone,copywithzone,C++,Cocos2d Iphone,Copywithzone,我有点麻烦 我制作了一些接口(c++中的抽象类)。在我的类中实现了它(也从CCObject派生)。 在第三个类中,我尝试调用接口的方法并得到SIGABORT。这是密码 //interface class class CallBackInterface { public: virtual void SomeMethod() = 0; }; //my class that implement the interface class MyClass : public

我有点麻烦

我制作了一些接口(c++中的抽象类)。在我的类中实现了它(也从CCObject派生)。 在第三个类中,我尝试调用接口的方法并得到SIGABORT。这是密码

 //interface class


class CallBackInterface
 {
 public:
       virtual void SomeMethod() = 0;
 };

 //my class that implement the interface 
 class MyClass : public CallBackInterface, public CCObject
 {
 public:
       void SomeMethod(){/*some realization*/}; 
 };

 //class that invoke the SomeMethod


class CallBacker()
 {
 public:
       CallBackInterface* callBackObject;
 };

 //main code


CallBacker* callBacker = new CallBacker();
 MyClass* myClass = new MyClass();
 callBacker->callBackObject = myClass;

/*
this string generate unexpected invoke of copyWithZone method CCObject's class
with SIGABORT. */

callBacker->callBackObject->SomeMethod();

/*
In debugger mode I see that SomeMethod don't invoke (debugger don't  go                                into it). Here the copyWithZone*/

CCObject* CCCopying::copyWithZone(CCZone *pZone)
    {
        CC_UNUSED_PARAM(pZone);
        CCAssert(0, "not implement"); <<- here is SIGABORT
        return 0;
    }
//接口类
类回调接口
{
公众:
虚拟方法()=0;
};
//实现接口的类
类MyClass:公共回调接口,公共CCObject
{
公众:
void SomeMethod(){/*某些实现*/};
};
//类调用SomeMethod
类回调函数()
{
公众:
CallBackInterface*callBackObject;
};
//主代码
CallBacker*CallBacker=newcallbacker();
MyClass*MyClass=新的MyClass();
callBacker->callBackObject=myClass;
/*
此字符串生成copyWithZone方法CCObject类的意外调用
带着SIGABORT*/
callBacker->callBackObject->SomeMethod();
/*
在调试器模式下,我看到SomeMethod不调用(调试器不进入它)。这里是copyWithZone*/
CCObject*CCCopy::copyWithZone(CCZone*pZone)
{
CC_未使用_参数(pZone);
CCAssert(0,“未实施”);

试试这个!我以前也遇到过同样的问题。

如果初始化正确,我认为问题出在代码的其他部分。在执行前的调试器中,您可以检查callBacker和callBackObject是否指向预期的地址吗?callBacker在所有这一切中的位置如何?对象的生命周期处理是否正确?规则3?我确实有同样的问题,有人能帮我解决这个问题吗?这是一件非常紧急的事情,我需要解决。
class CallBackInterface : public CCObject
{
public:
     virtual void SomeMethod() = 0;
};

class MyClass : public CallBackInterface
{
     void SomeMethod(){}
};