I'm trying to make a class that has a constructor with five parameters. The only thing the constructor does is pass all the parameters to the superclass constructor. This class doesn't have any extra variables: its only purpose is to change the implementation of the getClassType virtual function. For some reason, this header gives an "expected primary expression before '*' token" on line with the constructor, and it also gives four "expected primary expression before 'int'" on the same line:
#ifndef SUELO_H
#define SUELO_H
#include "plataforma.h"
#include "enums.h"
#include "object.h"
#include "Box2D/Box2D.h"
class Suelo : public Plataforma
{
public:
Suelo(b2World *world,int x,int y,int w,int h) : Plataforma(b2World* world,int x,int y,int w,int h){}
virtual ~Suelo();
virtual ClassType getClassType();
protected:
private:
};
#endif // SUELO_H
I assume these errors are caused by some typo, but I've checked on tutorials and on Google and I don't notice any mistake, so I'm stuck.
You don't pass the types into the base class constructor:
class A
{
public:
A(int) {};
}
class B : public A
{
public:
B(int x) : A(x) // notice A(x), not A(int x)
{}
};
So, you constructor should look like this:
Suelo(b2World *world,int x,int y,int w,int h) : Plataforma(world,x,y,w,h){}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With