<分区>
Possible Duplicate:
Why is there no call to the constructor?
What’s the effect of “int a(); ” in C++?
What’s the differences between Test t; and Test t();? if Test is a class
对于我正在尝试制作的游戏项目,出于某种原因忽略了我创建对象的指令。
项目刚刚开始,我不知道为什么会这样。
我使用 netbeans 作为 ide,g++ 作为编译器,操作系统是 ubuntu 12.10。
发生这种情况的代码是这样的:
#include "Vector.h"
#include"Motor.h"
int main(int argc, char** argv)
{
Motor m1();
return 0;
}
当我在“Motor m1();”上设置一个断点时并点击调试箭头跳转到它之后的返回指令并且不执行对象的构造函数
Motor 的代码是这样的:
#include "Motor.h"
Motor::Motor() {
SDL_Init(SDL_INIT_EVERYTHING);
pantalla=NULL;
pantalla=SDL_SetVideoMode(800,600,32,SDL_SWSURFACE);
SDL_Delay(2000);
}
Motor::~Motor() {
SDL_Quit();
}
“SDL_Delay(2000)”用于测试目的。
为什么会这样?