类变量未从构造函数初始化

时间:2013-10-31 00:30:48

标签: c++

我的Camera类构造函数有问题。我有许多变量,我正在构造函数中初始化,并为所有变量分配一些garbade值而不是我的。哪里可能是问题?例如printf("%d", yawSensitivity)输出-1610612736

我尝试尽可能少地粘贴代码。也许你会发现一个概念错误并指出我正确的方向......

Camera.h

class Camera
{
    protected:

        int windowMidX;
        int windowMidY;

        float pitchSensitivity; 
        float yawSensitivity; 

    public:

        Camera(int windowWidth, int windowHeight);
        ~Camera();
};

Camera.cpp

Camera::Camera(int windowWidth, int windowHeight)
{
    this->windowMidX = windowWidth  / 2;
    this->windowMidY = windowHeight / 2;

    this->pitchSensitivity = 0.1f; 
    this->yawSensitivity   = 0.1f;
}
Camera::~Camera() {}

相机初始化

Camera *cam = new Camera(WIN_WIDTH, WIN_HEIGHT);

0 个答案:

没有答案