我一直在使用 SDL 库开发程序。一切都在 Linux 中完成并且运行良好,移植到 Windows 时出现问题。当我构建并运行程序崩溃(程序停止工作)并关闭时,我首先认为它与 SDL 有关,但我将错误隔离到我刚刚定义二维数组或类对象的行. 类原型在头文件中定义,如下所示:
#ifndef PARTICULA_H
#define PARTICULA_H
class particula {
public:
particula();
particula(const particula& orig);
virtual ~particula();
int x,y;
int vx,vy;
int tipo;
int tipo2;
int peso;
int empuje;
bool update;
bool update_temp;
int contador;
int temperatura;
};
#endif
现在,在其 .cpp 文件中定义的类构造函数
particula::particula() {
vx = 0; vy = 0; tipo = 0; peso = 0; empuje = 0;
update = true; contador = 0; temperatura = 0;
update_temp = true; tipo2 = 0;
}
particula::particula(const particula& orig) {
}
particula::~particula() {
}
好的,在 main() 函数中,刚开始,我定义了这个类的一个数组:
particula matriz[400][220];
如果我构建并运行,程序会崩溃,如果我评论那一行,程序不会崩溃。不可能是别的,我已经评论了整个main
函数来找到它,所以那行是唯一执行的东西。会是什么呢?我做错什么了吗?