Updated code what my actual code is now and the error i have. Might be easier to fix like this..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
//main.cpp
#include "startup.h"
int main()
{
StartUp();
return 0;
}
//----------------------------------
#ifndef CHARACTER_CLASS_H
#define CHARACTER_CLASS_H
class Character
{
public:
Character();
//~Character();
//X and Y Location
int iX;
int iY;
//Stats
int health;
int damage;
//Boundries
int iPlayAreaTop;
int iPlayAreaBottom;
int iPlayAreaRight;
int iPlayAreaLeft;
};
Character::Character()
{
iPlayAreaTop = 0;
iPlayAreaBottom = 30;
iPlayAreaRight = 100;
iPlayAreaLeft = 0;
}
#endif //_CHARACTER_CLASS_H
//--------------------------------------------
//startup.cpp
#include <iostream>
#include "startup.h"
#include "createarmy.h"
Character GoodTeam; //Create an object of the class
Character *pGoodTeam = &GoodTeam; //Create a pointer to the address of GoodTeam
void StartUp()
{
std::cout << GoodTeam.iPlayAreaBottom << std::endl;
pGoodTeam->iPlayAreaBottom -= 10;
std::cout << GoodTeam.iPlayAreaBottom << std::endl;
}
//------------------------------------------------------------
//startup.h
#ifndef STARTUP_H
#define STARTUP_H
void StartUp();
#endif //_STARTUP_H
//------------------------------------------------------------
//createarmy.cpp
#include "createarmy.h"
void CreateArmy(Character *pCharacter)
{
pCharacter->health = 100;
pCharacter->damage = 25;
}
//-------------------------------------------------------------
//createarmy.h
#include "character_class.h"
#ifndef CREATEARMY_H
#define CREATEARMY_H
void CreateArmy(Character *pCharacter);
#endif //_CREATEARMY_H
//---------------------------------------------------
|
Ok so thats the current code and this is the output I'm getting:
1>------ Rebuild All started: Project: AIE_Game_For_Portfolio, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'AIE_Game_For_Portfolio', configuration 'Debug|Win32'
1>Compiling...
1>startup.cpp
1>main.cpp
1>createarmy.cpp
1>Generating Code...
1>Linking...
1>startup.obj : error LNK2005: "public: __thiscall Character::Character(void)" (??0Character@@QAE@XZ) already defined in createarmy.obj
1>startup.obj : error LNK2005: "public: __thiscall Character::Character(void)" (??0Character@@$$FQAE@XZ) already defined in createarmy.obj
1>C:\Documents and Settings\Scottie\My Documents\Visual Studio 2005\Projects\AIE_Game_For_Portfolio\Debug\AIE_Game_For_Portfolio.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Build log was saved at "file://c:\Documents and Settings\Scottie\My Documents\Visual Studio 2005\Projects\AIE_Game_For_Portfolio\AIE_Game_For_Portfolio\Debug\BuildLog.htm"
1>AIE_Game_For_Portfolio - 3 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Cheers guys, sorry for probably not explaining this properly but I'm really stumped why I can't get this working right :(