I can't use the addObject() of CCArray!

i have tried hundreds of times!so simple code can’t correctly run,who can tell me why?

CCArray * arr=CCArray::array();
CCSprite * sprite=CCSprite::create(“001.png”);
arr~~>addobject;//an assertion error occured here
i added arr~~>retain() but the error still occured.if there is no array,i couldn’t continue
coding.

arr->retain();
write this after CCArray create

thanks,it’s ok now!
maybe i am a bit thoughtless.

I am using COCOS 2dx 3.1

I declare

protected:
cocos2d::CCArray *_targets;
cocos2d::CCArray *_projectiles;

in header file

and i use

_targets = new CCArray;
_projectiles = new CCArray;

	_targets->retain();
	_projectiles->retain();

in init() funtion in cpp file

still got error on

_targets->addObject(target);

in addtarget() funtion in same cpp file

Problem Solved

I just change

from

targets = new CCArray;
projectiles = new CCArray;

To

_targets = CCArray::create();
_projectiles = CCArray::create();