• Advertisement
Sign in to follow this  

[SOLVED] 'Game' does not compile.

This topic is 1783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

 

I have my main.cpp:

#include "Game.h"

int main( int argc, char* args[] )
{
	Game game;
	game.Start();

	return 0;
}

 

My Game.cpp:

#include "Game.h"

class Game
{
	// Starts the game
	void Game::Start()
	{
		SDL_Init( SDL_INIT_EVERYTHING );

		SDL_Quit();
	}
};

 

And my Game.h:

#ifndef _GAME_H_
#define _GAME_H_

#include "SDL.h"
#include "SDL_image.h"

class Game
{
public:
	void Game::Start();
};

#endif // _GAME_H_

 

But when I compile I get this error:

1>------ Build started: Project: Pong Clone, Configuration: Debug Win32 ------
1>  main.cpp
1>  Game.cpp
1>c:\users\dennis\documents\visual studio 2012\projects\pong clone\pong clone\game.cpp(4): error C2011: 'Game' : 'class' type redefinition
1>          c:\users\dennis\documents\visual studio 2012\projects\pong clone\pong clone\game.h(8) : see declaration of 'Game'
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

How can I fix this?

Share this post


Link to post
Share on other sites
Advertisement

you have 2 definition of the class here's what it should look like 

 

header file 

 

 

class Game

{

    // Starts the game

    void Start();

};

 

cpp file

 

#include "Game.h"

 


void Game::Start()

{

    SDL_Init( SDL_INIT_EVERYTHING );

    SDL_Quit();

}

Edited by stevo5800

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement