Sign in to follow this  
NovaCaine

Problem defining a class in VC++ 2005

Recommended Posts

I know this will sounds n00bish, but i'm pretty sure I've written it right but i get a build error of my constructor trying to return a value .\src\Game.cpp(13) : error C2533: 'CGame::{ctor}' : constructors not allowed a return type and heres the code: Header
class CGame {
	public:
		CGame( HWND p_hWnd, int p_iWidth, int p_iHeight );
		~CGame();

		// Renders the world
		void RenderScene();
		
	private:

		// Initalizes D3D
		bool InitializeDirect3D(HWND hwnd);

		// Shutsdown and cleans up D3D
		void ShutdownDirect3D();

CPP
CGame::CGame( HWND p_hWnd, int p_iWidth, int p_iHeight ) {
	m_D3DDevice = NULL;
	m_D3DObject = NULL;

	m_iHeight = p_iHeight;
	m_iWidth = p_iWidth;

	InitializeDirect3D( p_hWnd );
}

CGame::~CGame() {

}

if i comment out the constructor and destructor i get build errors in my other functions of not having the same return type as the header. Also im just compiling this class. Any thoughts? and thanks in advance.

Share this post


Link to post
Share on other sites
Did you do something silly like forget the ; at the end of the class declaration?


class CGame {
public:
CGame( HWND p_hWnd, int p_iWidth, int p_iHeight );
~CGame();

// Renders the world
void RenderScene();

private:

// Initalizes D3D
bool InitializeDirect3D(HWND hwnd);

// Shutsdown and cleans up D3D
void ShutdownDirect3D();
};
^^^^^



That tends to get you odd errors like that.

Share this post


Link to post
Share on other sites
GRRRRRRRRRRRRRRRRR!!!!!!!!!!!!!!!!!!!!!

thats it!!! im sticking to one language only (for now)

been coding in Flash for the last month or to and got lazy. forgot about that.

Cheers all works now :D:D

Share this post


Link to post
Share on other sites
Not a prob!

I know what you mean; when moving between languages and/or environments it takes a bit to get your "sea legs" back!

Glad to help!

Share this post


Link to post
Share on other sites

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