【发布时间】:2014-11-30 09:53:33
【问题描述】:
所以,这是我的代码的一部分。
我有一个名为Polygon 的类,它有一个数组来保存我的坐标。
class Polygon{
private:
GLint Vertices[][2];
public:
Polygon(){
GLint** Vertices = new GLint*[20000];
for (int j=0; j<20000; j++){
Vertices[j] = new GLint[2];
}
}
void setCoord(int m, GLint x, GLint y){
Vertices[m][0] = x;
Vertices[m][1] = y;
}
};
我尝试编译我的代码,当我尝试将我的第一个坐标放入 setCoord() 函数的数组中时(当 m 为 0 时),我遇到了分段错误错误。
不知道为什么。希望你们会有所帮助。请不要告诉我有关向量的事情。我对这种技术不熟悉,而且我没有太多时间学习它,因为我的项目必须在 4 天内完成。
谢谢!
【问题讨论】:
-
你应该添加一个至少删除它们的析构函数。
标签: c++ arrays class opengl segmentation-fault