BOX2D b2World class: crash on myb2World = ab2World in my init method...

Hi,

I have got a class MainScene.cpp which has got a instance variable *world . In the init of this class MainScene.cpp, I want to do the “C++ translation” of the following iOS code:
<pre>
*ground = [[[Ground alloc] initWithWorld:*world];
</pre>
I wrote:
<pre>
*ground ->initWithWorld(*world);
</pre>
My ground class is like this:
ground.h
<pre>
class Terrain : public cocos2d::CCNode
{
protected:
b2World **world;
//some other code…
}

**ground.m**
bool Terrain::initWithWorld(b2World *aWorld) {
    if (CCNode::node())
    {
        _world = aWorld;
       //some other code...
    }
   return true;
}

I have got a crash on _world = aWorld; “Program received signal”EXC_BAD_ACCESS“”

I really don’t understand why…

Can anyone help me ?

Thanks a lot !

You had to alloc it first.

_ground = [[[Ground alloc] initWithWorld:_world];

to

_ground = new Ground;  // Equal to alloc. Beside this, _ground is a wild pointer.
_ground->initWithWorld(_world);