令牌之前的预期主表达式'*'
expected primary-expression before '*' token
我的代码中出现以下错误:
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h||In constructor 'deathBlock::deathBlock(GLuint*, float, float, float, float, float, float, float, float)':|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before '*' token|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before ',' token|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected primary-expression before 'float'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.h|9|error: expected '{' at end of input|
C:UsersSamuelDesktopTransferprojectstestMy_GamesrcdeathBlock.cpp|3|error: redefinition of 'deathBlock::deathBlock(GLuint*, float, float, float, float, float, float, float, float)'|
C:UsersSamuelDesktopTransferprojectstestMy_Gamesrc..includedeathBlock.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
另外,有人能告诉我一种使用搜索引擎搜索特殊字符的方法吗?这是因为我尝试过的所有方法都不允许这样做,这使得查找相关信息变得极其困难。
编辑:
这真是太愚蠢了,因为我刚刚将构造函数的参数直接复制到初始值设定项中,导致了我的错误。
GLunit
在#include <GL/gl.h>
中定义。在尝试使用类型之前,您需要包含该标头。
更具体地说,由于您使用的是glfw.h
,请检查您的定义,以确保包含gl.h
(例如,未定义GLFW_INCLUDE_NONE
),从而引入typedef
。
相关文章:
- holeMenuProgram.cpp:38:1 错误:'}'令牌之前的预期主表达式
- (错误:令牌之前'<<'预期的主表达式)
- 错误:C++中']'令牌之前的预期主表达式
- 错误:令牌之前的预期主表达式'&&'
- 令牌之前']'预期的主表达式?
- 错误:令牌之前的预期主表达式'/'
- 正则表达式使用提升令牌迭代器在单引号和括号之间提取值
- 令牌之前')'预期的主表达式(需要"template"消除歧义器)
- 错误:令牌之前的预期主表达式'<':Arduino RGB 舞灯
- 令牌之前出现错误')'主表达式
- C++错误:错误:令牌之前的预期主表达式'||'
- 令牌问题之前'*'预期的主表达式
- 令牌之前的预期表达式']'?C
- 退出状态 1 令牌之前的预期主表达式'.'
- C++错误:";"之前应为主表达式使用Cmake的令牌
- 向量空Push_back在令牌之前调用'{'预期的主表达式
- 令牌调用之前'...'预期的主表达式 模板化类的模板化方法
- 错误 预期主表达式在 ';" 之前令牌 C++
- 令牌之前的预期主表达式'-'
- 令牌之前的预期主表达式'<'