How to access member of Vector<MenuItem*>?

How to access member of Vector<MenuItem*>?
0.0 0


I have a vector of MenuItem here:

cocos2d::Vector<cocos2d::MenuItem*> menuItems;

This vector contains 4 MenuItemImages :


Now I’m trying to set selected and set active these image items through a KeyBoard Listener :

auto keyBoardListener = EventListenerKeyboard::create();
keyBoardListener->onKeyPressed = [&](cocos2d::EventKeyboard::KeyCode keycode, Event* event)
	switch (keycode)
	case cocos2d::EventKeyboard::KeyCode::KEY_LEFT_ARROW:
           // This should set myImage1 selected but it doesn't work
           // This should activates myImage2  but it doesn't work
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyBoardListener, this);

Visual Studio told me that There’s no operator “[]” matches these operands" .

Therefore, I dig into the CCVector.h and found that the operater [] function has been commented out with this comment:
// Don't uses operator since we could not decide whether it needs 'retain'/'release'.

So my question is, how could I access a member of the vector above? Your help is very much appriciated :D.



thanks a lot, can’t believe I don’t know the existance of at() function lol.