我想在一个struct点一个指针到另一种类型的结构的数组。这里是我的代码:调试断言失败 - C++
struct Mesh
{
long masterRef; // The global fragment number
long polygonCount; // Number of polygons in the mesh
long vertexCount; // Number of verticies in the mesh
Vertex *verti; // Pointer to verticies in the mesh
Poly *poly; // Pointer to polygons in the mesh
float center[3]; // The center of the mesh
bool isVisible; // Is the mesh currently visible?
} typedef Mesh;
struct Region
{
bool hasPoly;
long size1;
long size2;
long size3;
long size4;
long size5;
long size6;
Mesh* meshptr; // the mesh with the polygons for this region
long meshRef;
std::vector<int> visvector;
long regionsVisible;
};
正如你所看到的,我想创建区域结构网格指针。指针将指向网格数组中的Mesh。仅此行导致程序与调试断言失败的消息和崩溃“表达式:无效的空指针”
有谁知道这个问题可能是什么?我会发布调用代码,但它没有它崩溃。
我们需要调用代码! – James 2011-06-07 23:41:13
@James我完全删除了调用代码,它仍然崩溃。简单地注释掉Mesh * meshprt;导致它再次正常工作。 – 2011-06-07 23:44:52
@Satchmo布朗 - 给出消息 - '“表达式:无效空指针”,检查'meshptr'是否指向任何有效的位置使用调试器在崩溃的指针。你也违反了**三C++规则**。 – Mahesh 2011-06-07 23:46:57