2016-11-18 16 views
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.  

ありがとう:このように。ご挨拶docを読む

+1

'std :: vector'を意味しましたか?小文字(** v ** ectorとは対照的に** v ** ector)から始まりますか? –

+0

@AdrianColomitchi、私はそれが 'cocos2d :: Vector'だと思います – SingerOfTheFall

答えて

2

、それはあなたが禁止宣言をしようと思わ: - 要素の型

テンプレートは

Tパラメータ。

Tは、cocos2d :: Ref子孫オブジェクト型へのポインタでなければなりません。 cocos2d-Vectorのメモリ管理モデルをcocos2d :: Vectorに統合したので、他のデータ型やプリミティブは使用できません。 (v3.0ベータ版以来)

タイプTとしてcocos2d::Vectorを使用することはできません。

関連する問題