vendredi 25 septembre 2015

Error when overriding inherited function

The code for this class will not work

#include <windows.h>
#endif

#include <vector>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include <GL/freeglut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include "Tile.hpp"

class Platform : public Tile {

 public:
  using Tile::draw;
  void draw(void);
 private:
};

Here is the code for the following Tile class that I inherited from

#include <windows.h>
#endif

#include <vector>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include <GL/freeglut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include "Vector3d.hpp"

class Tile : public Vector3d {

 public:
  Tile();
  Tile(float xl, float yl, float zl);
  virtual void draw(void);
  void update(std::vector <bool> controls);

 private:
  float xv;
  float yv;
  float zv;

};

And I am getting the following error

src/Platform.o: In function `_GLOBAL__sub_I__ZN8Platform4drawEv':
/home/bkeys/Devel/moon/src/Platform.cpp:22: multiple definition of `Platform::draw()'
src/Platform.o:/home/bkeys/Devel/moon/src/Platform.cpp:22: first defined here
collect2: error: ld returned 1 exit status
Makefile:410: recipe for target 'moon' failed
make: *** [moon] Error 1

What I am trying to do is override the draw function in the Tile class and replace it with a draw function in the Platform class, other than that I want the two classes to be the same

Aucun commentaire:

Enregistrer un commentaire