Public Group

Errors, cant find why

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

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>

#include "ConLib.h"
#include "Player.h"

/* Game status enumerator */
enum GameStatus //error here
{
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 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 on other sites
there is something wrong with Player.h...
you probably forgot to add ; on the CPlayer class

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 on other sites
Quote:
 Original post by monkey4salenow 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?

Orginizing Code Files in C++

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631757
• Total Posts
3002139
×