0
我使用的是Cocos 2d-x,我需要創建一個類的對象的向量,但是當我嘗試創建它們時出現類型錯誤像這樣:如何創建一個類的對象向量的向量
header
Vector<Vector<Level*> > _stagesLevelsVec;
//Here's the type Error when I try to create a Vector of Vectors of Objects of Class Level
//Error: Invalid Type for cocos2d::Vector<T>!
//Last output line: see reference to class template instantiation 'cocos2d::Vector<cocos2d::Vector<Level *>>' being compiled
CPP
Level * level_0 = new Level; //I have to create an Object of Class Level
level_0->setLevel(0); //I have to set a Property of the Object using a Method of the Class.
Vector<Level *> allLevelsVec_0; //Here's the type Error when I try to create a Vector of Objects Level
//Error: Invalid Type for cocos2d::Vector<T>!
//Last output line: see reference to class template instantiation 'cocos2d::Vector<Level *>' being compiled
allLevelsVec_0.pushBack(level_0); //I have to add the Object into the Vector
_stagesLevelsVec.pushBack(allLevelsVec_0); //I have to add a Vector of Objets Level into a Vector
//Then somewhere in code
auto allLevelsVec = _stagesLevelsVec.at(0); // I have to get the Vector of Objects Level that I need
auto level = allLevelsVec.at(0); //I have to get the Object Level
auto levelId = level->getLevel(); //Finally I have to get the Property of level using a Method of the Class
CCLOG("This is level: %i", levelId); //Output must be: This is level: 0.
感謝在這個問題上的任何指引。問候。
你是不是指'std :: vector'?從小寫字母(** v ** ector而不是** V ** ector)開始? –
@AdrianColomitchi,我想它是'cocos2d :: Vector' – SingerOfTheFall