{ctor}不是<BaseClass>的成员

Che*_*ron 4 c++ inheritance constructor

我有一个名为GLObject的基类,带有以下标题:

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
};
Run Code Online (Sandbox Code Playgroud)

和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;
}
Run Code Online (Sandbox Code Playgroud)

接下来我有一个派生类:标题:

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);
    ...
};
Run Code Online (Sandbox Code Playgroud)

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)
{

}
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误:

glocolpiramid.cpp:4:错误:C2039:'{ctor}':不是'GLObject'的成员

为什么?

我使用Qt 4.8.4与MSVC2010 32位编译器

mas*_*oud 5

尝试GLObject::GLObject::GLObject声明中删除.

.cpp包含以下实现的文件中GLOColPiramid:

GLOColPiramid::GLOColPiramid( .... ) : GLObject::GLObject( .... )
                                       ^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

它在C++中是合法的,但测试它,也许MSVC2010有问题.