1

I am getting the following errors in my code:

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

I am trying to have a subclass run a superclass constructor upon it's creation, my code is as follows:

Superclass constructor:

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());
}

and superclass header:

#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

Subclass Constructor:

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
}

Subclass header:

#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

Additionally can someone point me towards a way to use a search engine to search for special characters? This is because all the ones I have tried don't allow this and this makes it exceedingly difficult to find relevant information.

EDIT:

This was exceedingly stupid of me, as I had just copied the parameters of the constructor straight to the initializer- causing my error.

user2673108
  • 309
  • 1
  • 5
  • 14
  • 2
    Why do you have all those *type* declarations in your base-class construction invoke? Try: `Block(Tex, x, y, texx, texy, texw, texh, w, h)` – WhozCraig Aug 26 '13 at 20:46
  • I am trying to do the following: http://stackoverflow.com/questions/120876/c-superclass-constructor-calling-rules – user2673108 Aug 26 '13 at 20:49
  • @WhozCraig Because they're (grammatically) illegal as only *expressions* are allowed here [class.base.init]/1 and this is the error the OP is looking for. Make that an answer. – dyp Aug 26 '13 at 20:50
  • The perils of cut and paste. – john Aug 26 '13 at 20:53
  • @user2673108 I know what you're *trying* to do. See luke's answer again. Note how he passes derived-constructor parameters to the base class? No type decls *in the invoke* (but obviously they must be present in the base constructors *declaration*). – WhozCraig Aug 26 '13 at 20:53
  • 1
    Also there's a semi colon you don't want. – john Aug 26 '13 at 20:55
  • @user2673108: Why are you not using initializer lists instead of assignments in your constructor? – Zac Howland Aug 26 '13 at 20:58
  • that was stupid of me, I just copied straight from the constructors parameters – user2673108 Aug 26 '13 at 23:31

1 Answers1

0

GLunit is defined in #include <GL/gl.h>. You need to included that header before you try to use the type.

More specifically, since you are using glfw.h, check your defines to make sure that gl.h is being included (e.g. GLFW_INCLUDE_NONE is NOT defined) so that the typedef is being brought in.

Zac Howland
  • 15,777
  • 1
  • 26
  • 42
  • http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Desktop-generic/LSB-Desktop-generic/libgl-ddefs.html It is about the 10th line down. – Zac Howland Aug 26 '13 at 21:01
  • [The `glfw.h` header file includes `GL/gl.h`.](http://www.glfw.org/docs/latest/quick.html) – dyp Aug 26 '13 at 21:07
  • @DyP: Hence the edit to tell him to check his defines to make sure it is being included. All of the includes in `glfw.h` are wrapped around platform defines. If one of those isn't set, it isn't going to be included. – Zac Howland Aug 26 '13 at 21:27