0

I have some trouble.

I made some interface (abstract class in c++). Implemented it in my class (derived from CCObject too). In third class I try to invoke method of interface and got SIGABORT. Here the code

 //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;
    }

The copyWithZone invokation crashes my app

Jaffa
  • 12,442
  • 4
  • 49
  • 101
monstr
  • 1,680
  • 1
  • 25
  • 44
  • You do initialization correctly, I think the problem is in some other part of code. In the debugger before execution can you check that callBacker and callBackObject point to the expected addresses? – nogard Oct 17 '12 at 12:28
  • Where is callBacker in all this? Are the lifetimes of your objects handled properly? Rule of 3? – CashCow Oct 17 '12 at 12:31
  • I do have same problem, can someone please help me on this. This is something very urgent for me to nail down. – user1908860 Apr 21 '13 at 00:05

1 Answers1

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

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

Try this! I met the same problem before.

imbahom
  • 1
  • 1