我有一个名为GLObject的基类,具有以下 header :

class GLObject{
    public:
        GLObject(float width = 0.0, float height = 0.0, float depth = 0.0,
                 float xPos= 0.0, float yPos = 0.0, float zPos =0.0,
                 float xRot =0.0, float yRot = 0.0, float zRot = 0.0);
    ... //Other methods etc
};

还有一个CPP:
GLObject::GLObject(float width, float height, float depth,
                    float xPos, float yPos, float zPos,
                    float xRot, float yRot, float zRot){
    this->xPos = xPos;
    this->yPos = yPos;
    this->zPos = zPos;
    this->xRot = xRot;
    this->yRot = yRot;
    this->zRot = zRot;
    this->width = width;
    this->height = height;
    this->depth = depth;
}

接下来,我有一个派生类:
header :
class GLOColPiramid : public GLObject
{
public:
    GLOColPiramid(float width, float height, float depth, float xPos = 0.0, float yPos = 0.0, float zPos = 0.0, float xRot = 0.0, float yRot = 0.0, float zRot = 0.0);
    ...
};

cpp文件
GLOColPiramid::GLOColPiramid(float width, float height, float depth, float xPos, float yPos, float zPos, float xRot, float yRot, float zRot) : GLObject::GLObject(width, height, depth, xPos,yPos,zPos,xRot,yRot,zRot)
{

}

这给我一个错误:



为什么?

我正在将Qt 4.8.4与MSVC2010 32位编译器一起使用

最佳答案

尝试从声明中的GLObject::中删除GLObject::GLObject

.cpp文件中,其中包含GLOColPiramid的实现:

GLOColPiramid::GLOColPiramid( .... ) : GLObject::GLObject( .... )
                                       ^^^^^^^^^^

在C++中是合法的,但要对其进行测试,也许MSVC2010对此有问题。

10-07 12:30