Sign in to follow this  

Errors, cant find why

This topic is 3492 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

While using working through some tutorials I managed to develop a compiler error which I cant resolve. C2533, A constructor cannot have a return type (not even a void return type). but I dont specify a return type
/* CPlayer complement header */
#include "Player.h"
#include <windows.h>

/* Does Nothing */
CPlayer::CPlayer() //Error here
{
}
/* Does nothing */
CPlayer::~CPlayer()
{
}
Player.h contains the class information, while the methods and such are in a source file, I dont understand why the book is doing it this way, but im rolling with it. I also get an error when I try to use an enumerator.
/* Windows standard header file */
#include <windows.h>
/* Standard input/output header file */
#include <stdio.h>

/* ConLib header file */
#include "ConLib.h"
/* CPlayer header file */
#include "Player.h"

/* Game status enumerator */
enum GameStatus //error here
{
	GameMainMenu		= 1,
	GameRunning			= 2,
	GamePaused			= 3,
	GameWon				= 4,
	GameLostLife		= 5,
	GameLost			= 6,
	GameExit			= 7,
	GameSplashScreen	= 8
};

/* game difficulty enumerator */
enum GameDifficulty
{
	GameEasy		=1,
	GameMedium		=2,
	GameDifficult	=3
};
"unexpected 'enum' 'GameStatus'. Did you forget a ';'?" any reason for this one?

Share this post


Link to post
Share on other sites
As the error says 'did you forget a semicolon?'. You need to place a semicolon after the closing } for a class declaration. It's an easy one to miss, and since both files include Player.h it could be causing both errors. Have a look in Player.h.

Share this post


Link to post
Share on other sites
lol, gratz, hate those small things.

1 semicolon between 6 files, results in 12 errors.... depressing


now the book splits up the classes into source files and header files, wouldnt it be easier to have one header file instead of two different files?

Share this post


Link to post
Share on other sites

This topic is 3492 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this