Jump to content
  • Advertisement
Sign in to follow this  
zealotgi

Pre Compile Errors

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

Ok, I need help on debugging this code so that it will compile right. Heres the header...
// Button class header, for laying buttons and detecting when mouse over
#ifndef _BUTTONS_H_
#define _BUTTONS_H_

class cButton
{
	private:
		cGraphics	*m_Graphics;
		cTexture	*m_TxButtons;

		int		Buttons[256];
		int		bSrcX[256], bSrcY[256], bWidth[256], bHeight[256], bXScale[256], bYScale[256], bDestX[256], bDestY[256];

	public:
		BOOL	Load(char *FileName);
		BOOL	Create(int ButtonNumber, int SrcX, int SrcY, int Width, int Height, float XScale = 1.0f, float YScale = 1.0f);
		BOOL	Render(int ButtonNumber, int DestX, int DestY, D3DCOLOR Color = D3DCOLOR_RGBA(255,255,255,255), BOOL UseHoverImg = FALSE);
		BOOL	IsMouseOver(int ButtonNumber);
};

#endif

The actual code...
#include "Global.h"

BOOL cButton::Load(char *FileName);
{
	m_TxButtons->Load(m_Graphics, FileName)
}

BOOL cButton::Create(int ButtonNumber, int SrcX, int SrcY, int Width, int Height, float XScale, float YScale);
{
	int i = ButtonNumber;

	bSrcX	= SrcX;
	bSrcY	= SrcY;
	bWidth	= Width;
	bHeight	= Height;
	bXScale	= XScale;
	bYScale      = YScale;
}

BOOL cButton::Render(int ButtonNumber, int DestX, int DestY, BOOL UseHoverImg, D3DCOLOR Color);
{
	int	i		= ButtonNumber;
	static BOOL IsMouseOver	= FALSE;

	bDestX = DestX;
	bDestY = DestY;

	if(IsMouseOver == FALSE);
		m_TxButtons->Blit(bDestX, bDestY, bSrcX, bSrcY, bWidth, bHeight, bXScale, bYScale, Color);
	else
		m_TxButtons->Blit(bDestX, bDestY, bSrcX, (bSrcY + bHeight), bWidth, bHeight, bXScale, bYScale, Color);
	
	if(UseHoverImg == TRUE)
		if((mXPos > bDestX) && (mXPos < (bDestX + bWidth)) && (mYPos > bDestY) && (mYPos < (bDestY + bHeight)))
			IsMouseOver == TRUE;
	
}

BOOL cButton::IsMouseOver(int ButtonNumber);
{
	int i		= ButtonNumber;
	int mXPos	= (int)m_App->m_Mouse.GetXPos();
	int mYPos	= (int)m_App->m_Mouse.GetYPos();

	if((mXPos > bDestX) && (mXPos < (bDestX + bWidth)) && (mYPos > bDestY) && (mYPos < (bDestY + bHeight)))
		return TRUE;
	
	return FALSE;
}

Here's the errors:
Quote:
error C2761: 'BOOL cButton::Load(char *)' : member function redeclaration not allowed error C2447: '{' : missing function header (old-style formal list?) error C2761: 'BOOL cButton::Create(int,int,int,int,int,float,float)' : member function redeclaration not allowed error C2447: '{' : missing function header (old-style formal list?) error C2761: 'BOOL cButton::Render(int,int,int,D3DCOLOR,BOOL)' : member function redeclaration not allowed error C2447: '{' : missing function header (old-style formal list?) error C2761: 'BOOL cButton::IsMouseOver(int)' : member function redeclaration not allowed error C2447: '{' : missing function header (old-style formal list?)
Thanks!

Share this post


Link to post
Share on other sites
Advertisement
In all your source code, you must not have semicolons in the function name!

BOOL cButton::Load(char *FileName) // no semicolon
{
m_TxButtons->Load(m_Graphics, FileName)
}

BOOL cButton::Create(int ButtonNumber, int SrcX, int SrcY, int Width, int Height, float XScale, float YScale)// no semicolon
{
int i = ButtonNumber;

bSrcX = SrcX;
bSrcY = SrcY;
bWidth = Width;
bHeight = Height;
bXScale = XScale;
bYScale = YScale;
}

BOOL cButton::Render(int ButtonNumber, int DestX, int DestY, BOOL UseHoverImg, D3DCOLOR Color) // no semicolon
{
int i = ButtonNumber;
static BOOL IsMouseOver = FALSE;

bDestX = DestX;
bDestY = DestY;

if(IsMouseOver == FALSE);
m_TxButtons->Blit(bDestX, bDestY, bSrcX, bSrcY, bWidth, bHeight, bXScale, bYScale, Color);
else
m_TxButtons->Blit(bDestX, bDestY, bSrcX, (bSrcY + bHeight), bWidth, bHeight, bXScale, bYScale, Color);

if(UseHoverImg == TRUE)
if((mXPos > bDestX) && (mXPos < (bDestX + bWidth)) && (mYPos > bDestY) && (mYPos < (bDestY + bHeight)))
IsMouseOver == TRUE;

}

BOOL cButton::IsMouseOver(int ButtonNumber) // no semicolon
{
int i = ButtonNumber;
int mXPos = (int)m_App->m_Mouse.GetXPos();
int mYPos = (int)m_App->m_Mouse.GetYPos();

if((mXPos > bDestX) && (mXPos < (bDestX + bWidth)) && (mYPos > bDestY) && (mYPos < (bDestY + bHeight)))
return TRUE;

return FALSE;
}




This is because you are making the implementation, which is not ended at the ending parenthesis, like a prototype is.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!