1

我的代码中出现以下错误:

C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h||In constructor 'deathBlock::deathBlock(GLuint*, float, float, float, float, float, float, float, float)':|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before '*' token|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before ',' token|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected primary-expression before 'float'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|9|error: expected '{' at end of input|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\deathBlock.cpp|3|error: redefinition of 'deathBlock::deathBlock(GLuint*, float, float, float, float, float, float, float, float)'|
C:\Users\Samuel\Desktop\Transfer\projects\test\My_Game\src\..\include\deathBlock.h|8|error: 'deathBlock::deathBlock(GLuint*, float, float, float, float, float, float, float, float)' previously defined here|
||=== Build finished: 13 errors, 0 warnings (0 minutes, 0 seconds) ===|

我试图让一个子类在创建时运行一个超类构造函数,我的代码如下:

超类构造函数:

Block::Block (GLuint *Tex, float x, float y,float texx,float texy,float texw,float texh,float w,float h) {
    tex = Tex;
    Setmx (x);
    setsxw(w);
    setsyw(h);
    tx=texx;
    ty=texy;
    tw=texw+tx;
    th=texh+ty;
    Setmy (y);
    setsx (x + Getxoffset() );
    setsy (y+Getyoffset());
}

和超类标题:

#ifndef BLOCK_H
#define BLOCK_H
#include "../include/MapObject.h"
#include <GL/glfw.h>
class Block: public MapObject {
public:
    Block(GLuint *, float x, float y,float,float,float,float,float,float);
    virtual ~Block();
    void render();
    virtual void onIntersect();
protected:
private:
    float tx,ty,tw,th;
    GLuint * tex;
};

#endif // BLOCK_H

子类构造函数:

deathBlock::deathBlock(GLuint *Tex, float x, float y,float texx,float texy,float texw,float texh,float w,float h)
:Block(GLuint *Tex, float x, float y,float texx,float texy,float texw,float texh,float w,float h);
{
    //ctor
}

子类标题:

#ifndef DEATHBLOCK_H
#define DEATHBLOCK_H
#include <GL/glfw.h>
#include "../include/Block.h"
class deathBlock:public Block
{
    public:
        deathBlock(GLuint *Tex, float x, float y,float texx,float texy,float texw,float texh,float w,float h);
        virtual ~deathBlock();
    protected:
    private:
};

#endif // DEATHBLOCK_H

此外,有人可以指出我使用搜索引擎搜索特殊字符的方法吗?这是因为我尝试过的所有方法都不允许这样做,这使得找到相关信息变得非常困难。

编辑:

这对我来说非常愚蠢,因为我刚刚将构造函数的参数直接复制到了初始化程序中——导致了我的错误。

4

1 回答 1

0

GLunit中定义#include <GL/gl.h>。在尝试使用该类型之前,您需要包含该标题。

更具体地说,由于您正在使用glfw.h,请检查您的定义以确保gl.h包含(例如GLFW_INCLUDE_NONE未定义)以便typedef引入。

于 2013-08-26T20:56:45.210 回答