I'm getting a very strange (to me at least) error when compiling my project in these 3 lines where I declare an object of class InitGameData called Init:
InitGameData Init;
void Init.SetScreenResX(800);
void Init.SetScreenResY(600);
I get 6 errors, 3 per line, here is the Compile Log:
------ Build started: Project: BiggerFish, Configuration: Release Win32 ------
Compiling...
BiggerFish.cpp
.\BiggerFish.cpp(23) : error C2143: syntax error : missing ';' before '.'
.\BiggerFish.cpp(23) : error C2182: 'Init' : illegal use of type 'void'
.\BiggerFish.cpp(23) : error C2371: 'Init' : redefinition; different basic types
.\BiggerFish.cpp(22) : see declaration of 'Init'
.\BiggerFish.cpp(24) : error C2143: syntax error : missing ';' before '.'
.\BiggerFish.cpp(24) : error C2182: 'Init' : illegal use of type 'void'
.\BiggerFish.cpp(24) : error C2371: 'Init' : redefinition; different basic types
.\BiggerFish.cpp(22) : see declaration of 'Init'
.\BiggerFish.cpp(227) : warning C4996: 'strcpy' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
.\BiggerFish.cpp(234) : warning C4996: 'strcpy' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
.\BiggerFish.cpp(241) : warning C4996: 'strcpy' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
.\BiggerFish.cpp(289) : warning C4996: 'strcpy' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
Build log was saved at "file://c:\Documents and Settings\Hillam\My Documents\Visual Studio 2005\Projects\BiggerFish\BiggerFish\Release\BuildLog.htm"
BiggerFish - 6 error(s), 4 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And the sourcecode for my class:
//////////////////////////////////////////////////////
// InitGameData.h
//////////////////////////////////////////////////////
#pragma once
class InitGameData
{
private:
unsigned int i_ScreenResX;
unsigned int i_ScreenResY;
public:
InitGameData(void);
~InitGameData(void);
void SetScreenResX(int ScreenResX);
int GetScreenResX();
void SetScreenResY(int ScreenResY);
int GetScreenResY();
};
And it's Declarations:
//////////////////////////////////////////////////////
// InitGameData.cpp
//////////////////////////////////////////////////////
#include "InitGameData.h"
#include "Fish.h"
//////////////////////////////////////////////////////
// InitGameData()
//////////////////////////////////////////////////////
InitGameData::InitGameData(void)
{
Fish Player1;
Player1.SetLevel(0);
Player1.SetExp(0);
Player1.SetMoveSpeed(5);
Player1.SetMoveDirection("Left");
Player1.SetLocationX(GetScreenResX() / 2);
Player1.SetLocationY(GetScreenResY() / 2);
Fish NPC1;
NPC1.SetLevel(2);
NPC1.SetExp(5);
NPC1.SetMoveSpeed(5);
NPC1.SetMoveDirection("Right");
NPC1.SetLocationX(600);
NPC1.SetLocationY(250);
}
//////////////////////////////////////////////////////
// ~InitGameData()
//////////////////////////////////////////////////////
InitGameData::~InitGameData(void)
{
}
//////////////////////////////////////////////////////
// SetScreenResX()
//////////////////////////////////////////////////////
void InitGameData::SetScreenResX(int ScreenResX)
{
i_ScreenResX = ScreenResX;
}
//////////////////////////////////////////////////////
// GetScreenResX()
//////////////////////////////////////////////////////
int InitGameData::GetScreenResX(void)
{
return i_ScreenResX;
}
//////////////////////////////////////////////////////
// SetScreenResY()
//////////////////////////////////////////////////////
void InitGameData::SetScreenResY(int ScreenResY)
{
i_ScreenResY = ScreenResY;
}
//////////////////////////////////////////////////////
// GetScreenResY()
//////////////////////////////////////////////////////
int InitGameData::GetScreenResY(void)
{
return i_ScreenResY;
}
Any ideas? I am really sick of getting erros that seem to have nothing to do with what it says it is. Why on earth would I want to put a semicolon in front of a period? I checked the help files for these errors but that didn't seem to help...