我正在尝试制作一个包含多种数据类型和向量的数据树。到目前为止我所拥有的如下所示:
struct VertStruct{
double X, Y, Z;
};
struct FaceStruct{
int F1, F2, F3, F4;
};
struct FaceNormalStruct{
double X, Y, Z;
};
struct LODStruct{
std::vector<VertStruct> Verts;
std::vector<FaceStruct> Faces;
std::vector<FaceNormalStruct> FaceNormals;
};
struct ChunkStruct{
std::vector<LODStruct> LOD;
};
int main(){
std::vector<ChunkStruct> Chunk;
Chunk.resize(100);
for(int i = 0; i < 100; i++)
{
Chunk[i].LOD.resize(5);
for(int j = 0; j < 5; j++)
{
Chunk[i].LOD[j].Verts.resize(36);
Chunk[i].LOD[j].Faces.resize(25);
Chunk[i].LOD[j].FaceNormals.resize(25);
}
}
return 1;
}
现在这编译得很好,这正是我想要的,但是,如果我尝试将一个值设置为:
int Number = 42;
Chunk[5].LOD[4].Verts[3] = Number;
然后我收到以下错误:
main.cpp|126|error: no match for 'operator=' in 'Chunk.std::vector<_Tp, _Alloc>::operator[] [with _Tp = ChunkStruct, _Alloc = std::allocator<ChunkStruct>](5u)->ChunkStruct::LOD.std::vector<_Tp, _Alloc>::operator[] [with _Tp = LODStruct, _Alloc = std::allocator<LODStruct>](4u)->LODStruct::Verts.std::vector<_Tp, _Alloc>::operator[] [with _Tp = VertStruct, _Alloc = std::allocator<VertStruct>](3u) = Number'|
那么我是否遗漏了什么,或者我试图做的事情是不可能的?