Can not count CCArray.

Dear all,
I want to count objects in CCArray but getting error (Access Violation) as in image.
I’m using visual studio express 2012 and windows 8.
This is my .h file:

class Item : public cocos2d::CCLayer
{
public:
————————
cocos2d::CCArray *items;
————————
}

.cpp file:

bool Item::init()
{
————————-
items = CCArray::create();
items~~>retain;
————————~~
for(int i = 1; i <= 6; j++){
items~~>addObject;
}
————————~~
}

int Item::countItems()
{
return items~~>count;
}
I call the countItems from other file:
——————
Item p;
int itemsCount = p.countItems;
——————
Error occured in item~~>count() in count method.
Please Help!


Untitled.png (9.2 KB)

countItems returns an int.
why r u casting the result as ccarray

Thanks for reply. Sorry for annoy. I confuse to edit code, it’s int, not casting, now I found the solution. I just need to declare cocos2d::CCArray *items; in cpp file and the problem gone. I have no idea why.