Hello :D
I have a really REALLY weird problem that I am really frustrated by.
I am a novice programmer, and I decided to mess with some classes...
Anyway, long story short, I defined a bunch of classes, and one of the I made with inheritance from another one. but I get the errors(Edit 1):
graphic.h(3): error C2011: 'Graphic' : 'class' type redefinition
graphic.h(3) : see declaration of 'Graphic'
dot.h(5): error C2504: 'Graphic' : base class undefined
Now I checked every single line of code for a missing semicolon or a curly bracket (which from my earlier experience caused lots of similar problems) and apparently nothing is missing!
I checked the Classes tutorials on this website and it seems I am doing everything right...
Edit 1: added 2 more errors, and updated the code.
The files I use (Sorry for the huge amount, but its all the files I have so yeah): ##If you don't mind- Ignore the fact that this program won't work, I am aware of the fact. I was in the middle of turning everything to classes, so none of the classes are actually getting created during run time (if it will even get trough compiling any time soon...)##
Also I split the Headers in this post and CPPs on the next one, due to letter limit
class Timer
{
private:
int startTicks; //The clock time when the timer started
int pausedTicks; //The ticks stored when the timer was paused
bool paused;
bool started;
public:
Timer(); //Initializes variables
void start();
void stop();
void pause();
void unpause();
int get_ticks(); //Gets the timer's time
bool is_started();
bool is_paused();
};
graphic.h:
1 2 3 4 5 6 7 8
class Graphic
{
protected:
SDL_Surface* image;
void kill();
void load_image(std::string filename);
void apply_surface(int x, int y, SDL_Surface* destination, SDL_Rect* clip);
};
dot.h:(Edit 1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include "SDL.h"
#include "graphic.h"
class Dot: public Graphic
{
private:
int x, y; //The X and Y offsets of the dot
int xVel, yVel; //The velocity of the dot
public:
Dot(); //Initializes the variables
void handle_input(SDL_Event &event); //Takes key presses and adjusts the dot's velocity
void move(); //Moves the dot
void show(); //Shows the dot on the screen
void set_camera(); //Sets the camera over the dot
};
Dot has no knowledge of Graphic, from what I can see in your code. In other words where is Graphic header in the Dot files? Make sure in each place you use something you have a matching header file.
Oh... someone once told me that including is almost the same as copying the same code instead.
And due to a few redefinition errors I once had, I was afraid of making them ever since, thanks for the tip :)
Back to my problem, I don't remember if it were before or not, but after I did what you told me, I noticed two more errors that accompany the previous one:
graphic.h(3): error C2011: 'Graphic' : 'class' type redefinition
graphic.h(3) : see declaration of 'Graphic'
dot.h(5): error C2504: 'Graphic' : base class undefined