#ifndef _DotNTimer_H_
#define _DotNTimer_H_
#include "SDL/SDL.h"
// The timer
class Timer
{
private:
// The clock time when the timer started
int startTicks;
// The ticks stored when the timer was paused
int pausedTicks;
// The timer status
bool paused;
bool started;
public:
Timer();
void start();
void stop();
void pause();
void unpause();
int get_ticks();
bool is_started();
bool is_paused();
};
// The dot that will move around on the screen
class Dot
{
private:
// The X and Y offsets of the dot
int x, y;
// The velocity of the dot
int xVel, yVel;
public:
// Initializes the variables
Dot();
// Takes key presses and adjusts the dot's velocity
void handle_input();
// Moves the dot
void move();
// Shows the dot on the screen
void show();
};
#endif
Thank you very much for the resource. Once I added extern both it worked but i'm a little bit confused. The link said:
"a const-qualified object at file scope" but this isn't an object. Now what I'm also confused about is what does that make the initialized variable? a definition or a declaration? Is this a keyword used for situations like this or is there something more?
Objects with the const specifier have internal linkage. So these definitions
//The screen attributes
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;
//The dimensions of the dot
const int DOT_WIDTH = 20;
const int DOT_HEIGHT = 20;
are visible only in translation units that contain this header.
There is no need to define them as external. You can simply include a header where they are defined in each translation unit. Or you can declare them as external but define them only in one module.
Nevermind I think i got it. Seems I misunderstood the concept of extern which merely makes the variable of external linkage but doesn't determine whether a variable is a definition or declaration. Thank you once again ne555.
if a variable with specifier extern has no an initializer then it is declared (not defined). If a variable with specifier extern has an initializer then it is defined.