I've made a program that generates a Character's details(Game details, like level, name, HP, etc, based on a few parameters). I've added another .cpp file to it [without a main() function], but when I try to compile the whole project in Dev-Cpp, it just shows an error. My code is:
#include <iostream>
#include <fstream>
#include <string>
#include "character.h"
#define ReadCharacterFromThisFile "CharacterRecord.def"
Character AssignCharacter;//Class Declaration
void ReadCharacter()
{
std::string TempReadCharacter;
bool tempVar=false;
AssignCharacter.LineCount=0;
unsigned int Potency;
double hp, off, def, mod;
std::ifstream ReadThisCharacter(ReadCharacterFromThisFile, std::ios::in);
while(std::getline(ReadThisCharacter, TempReadCharacter, '\n'))
{
AssignCharacter.LineCount++;
}
for(unsigned int l=0; l <= AssignCharacter.LineCount; l++)
{
TempReadCharacter="";
if(l == 3)
{
ReadThisCharacter >> TempReadCharacter;
std::cout << "\n\n\tCharacter's Name:: " << AssignCharacter.EncryptDecrypt(TempReadCharacter) << "\n\n\t";
}
if(l == 4)
{
ReadThisCharacter >> TempReadCharacter;
std::cout << "Spell Used:: " << AssignCharacter.EncryptDecrypt(TempReadCharacter);
}
if(l == 5)
{
ReadThisCharacter >> TempReadCharacter;
std::cout << "\n\n\tCharm Used:: " << AssignCharacter.EncryptDecrypt(TempReadCharacter);
}
if(l == 6)
{
ReadThisCharacter >> TempReadCharacter;
std::cout << "\n\n\tCurse Used:: " << AssignCharacter.EncryptDecrypt(TempReadCharacter);
}
if(l == 7)
{
ReadThisCharacter >> tempVar;
std::cout << "\n\n\tVeritaserum Marker (Spell):: " << tempVar;
}
if(l == 8)
{
tempVar=false;
ReadThisCharacter >> tempVar;
std::cout << "\n\n\tVeritaserum Marker (Charm):: " << tempVar;
}
if(l == 9)
{
tempVar=false;
ReadThisCharacter >> tempVar;
std::cout << "\n\n\tVeritaserum Marker (Curse):: " << tempVar;
}
if(l == 10)
{
ReadThisCharacter >> AssignCharacter.identifier;
}
if(l == 11)
{
ReadThisCharacter >> Potency;
}
if(l == 12)
{
ReadThisCharacter >> hp;
}
if(l == 13)
{
ReadThisCharacter >> off;
}
if(l == 14)
{
ReadThisCharacter >> def;
}
if(l == 15)
{
ReadThisCharacter >> mod;
}
}
}
This code when compiled with the main project, gives this compiler error:
multiple definition of `ReadCharacter()'
first defined here
multiple definition of `AssignCharacter'
first defined here
ld returned 1 exit status
C:\Documents and Settings\Admin\My Documents\OOC++\HP\Makefile.win [Build Error] [HP.exe] Error 1
with no line references! I can't find where these have been defined before!
Could anyone help with this?