Member Intilization Error

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef _GAME_H_
    #define _GAME_H_

#include <SDL/SDL.h>
//#include "game.cpp"

class game {
    public:
        game();
        bool bisrunning;
        void gamerun();

    private:
};

game::game() {
    bisrunning = true;
}


#endif 

I get:
E:\CodeBlocks\Games\Doom_Shooter\game.h|16|warning: 'game::bisrunning' should be initialized in the member initialization list|
Why do I get this error?
It's being strict - what you have is legal but not best practice.

The member initialisation list would be:

1
2
3
game::game() : bisrunning(true)
{
}


Jim
Also the code for all the game class member functions should go in game.cpp not in the header file.

Don't be tempted include .cpp files

HTH
Thanks got it working. :D
Topic archived. No new replies allowed.