I created these three files and put them in the same folder. I am using Ubuntu. I tried to compile this with both gcc and g++ commands.. but i am getting errors like this,
g++ game.h main.cpp game.cpp
game.cpp:3: error: ‘Game’ has not been declared
Can you show me the correct way to do this?
also what i relly want to do is put main.cpp and game.cpp files in "Source Files" folder and keep game.h file in "Header Files" folder.
(I have a little experience with C language and Java.) main.cpp
1 2 3 4 5 6 7 8 9 10 11 12
#include <stdlib.h>
#include <stdio.h>
#include "game.h"
int main()
{
printf("BEGINS\n");
Game game;
game.run();
printf("ENDS\n");
return 0;
}
game.h
1 2 3 4 5
class Game
{
public:
bool run(void);
};
game.cpp
1 2 3 4 5 6 7
#include <stdio.h>
bool Game::run(void)
{
printf("running the game\n");
returntrue;
}