C++ 如何创建类的对象的向量向量

C++ 如何创建类的对象的向量向量,c++,vector,cocos2d-x,C++,Vector,Cocos2d X,我正在使用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&

我正在使用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
标题
向量_stagesLevelsVec;
//当我试图创建类级别的对象的向量向量时,这里有一个类型错误
//错误:cocos2d::Vector的类型无效!
//最后一行输出:请参阅对正在编译的类模板实例化“cocos2d::Vector”的引用
cpp

Level*Level\u 0=新级别//我必须创建一个类级别的对象
级别0->设置级别(0)//我必须使用类的方法设置对象的属性。
向量allLevelsVec_0//下面是我尝试创建对象级别的向量时出现的类型错误
//错误:cocos2d::Vector的类型无效!
//最后一行输出:请参阅对正在编译的类模板实例化“cocos2d::Vector”的引用
所有标高0.回推(标高0)//我必须把这个物体加到向量上
_阶段级别EC.pushBack(所有级别EC_0)//我必须在向量中添加一个对象级别的向量
//然后在代码中的某个地方
auto ALLEVESVEC=_stagesLevelsVec.at(0);//我必须得到我需要的物体的向量
自动调平=在(0)处的所有调平//我必须得到对象级别
auto-levelId=level->getLevel()//最后,我必须使用类的方法获得level的属性
CCLOG(“这是级别:%i”,级别ID)//输出必须为:这是级别:0。
谢谢你对这件事的指导。您好。

在阅读时,您似乎尝试了一个禁止声明:

模板参数

T-元素的类型

T必须是指向cocos2d::Ref子体对象类型的指针。不允许使用其他数据类型或原语,因为我们已经将cocos2d-x的内存管理模型集成到cocos2d::Vector中。(自v3.0测试版起)

您不能将
cocos2d::Vector
用作类型
t

读取,似乎您尝试了禁止声明:

模板参数

T-元素的类型

T必须是指向cocos2d::Ref子体对象类型的指针。不允许使用其他数据类型或原语,因为我们已经将cocos2d-x的内存管理模型集成到cocos2d::Vector中。(自v3.0测试版起)


您不能将
cocos2d::Vector
用作类型
t

您的意思是
std::Vector
?从一个小写字母开始(vector与vector相对)?@AdrianColomitchi,我想它是
cocos2d::vector
你的意思是
std::vector
?从一个小写字母开始(vector与vector相对)?@AdrianColomitchi,我想它是
cocos2d::vector
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.