I'm learning how to write a roguelike, and it's pretty much the first real programming project i have ever done. I have studied C++ for a bit at school and on my spare time, but i know only the basics, and i thought that programming a simple game would be good learning. I'm trying to make a character creator where you choose a race and a class, then the program rolls your stats, adding different bonuses based on classes and races, but i run into this error:
100 C:\Dev-Cpp\char.c statement cannot resolve address of overloaded function
I'm trying to write the stats to a simple text file, but the program tells me that. What gives?
Name:
Anonymous2006-07-16 14:53
Ok, i know the code sucks major amounts of ass, bear with me:
int main()
{
character creating;
cout<<"Creating a new character, choose a race:\n";
cout<<"1.) Mutant\n2.) Robot\n3.) Human\n";
cin>>creating.Race;
clear();
cout<<"Choose a profession for your character:\n";
cout<<"1.) Brute\n2.) Gunslinger\n3.) Scientist\n";
cin>>creating.Class;
clear();
cout<<"Choose a name: ";
cin>>creating.name[256];
stats();
}
int clear()
{
system("cls");
}
int stats()
{
int e = 1;
int r = 2;
int t = 3;
character creating;
srand((unsigned)time(0));
if ( creating.Race == e ) //1 is mutant.
{
character creating;
creating.Str = (rand()%5)+(rand()%5)+18;
creating.Dex = (rand()%5)+(rand()%5)+10;
creating.Int = (rand()%5)+(rand()%5)+5;
creating.Tou = (rand()%8)+(rand()%8)+15;
creating.Sen = (rand()%6)+(rand()%6)+6;
creating.HP = creating.Str/3 + creating.Tou/2 + (rand()%10);
creating.SP = creating.Int/2 + creating.Sen/3 + (rand()%10); //sum is 64
}
if ( creating.Race == r ) //2 is a space robot, protecting you from the secret of space.
{
character creating;
creating.Str = (rand()%6)+(rand()%6)+6;
creating.Dex = (rand()%8)+(rand()%8)+15;
creating.Int = (rand()%5)+(rand()%5)+10;
creating.Tou = (rand()%5)+(rand()%5)+5;
creating.Sen = (rand()%5)+(rand()%5)+18; //64 here too
creating.HP = creating.Str/3 + creating.Tou/2 + (rand()%10);
creating.SP = creating.Int/2 + creating.Sen/3 + (rand()%10);
}
if ( creating.Race == t ) //3 is a MUNDANE HYOOOOOMAAAAN.
{
creating.Str = (rand()%5)+(rand()%5)+13;
creating.Dex = (rand()%5)+(rand()%5)+13;
creating.Int = (rand()%5)+(rand()%5)+13;
creating.Tou = (rand()%5)+(rand()%5)+13;
creating.Sen = (rand()%5)+(rand()%5)+12; //And here too, gotta be balanced mon.
creating.HP = creating.Str/3 + creating.Tou/2 + (rand()%10);
creating.SP = creating.Int/2 + creating.Sen/3 + (rand()%10);
}
if ( creating.Class == e ) //Brute
{
creating.Str++;
creating.Tou++;
creating.Int--;
}
if ( creating.Class == r ) //Gunslinger
{
creating.Sen++;
creating.Dex++;
creating.Str--;
}
if ( creating.Class == t ) //Scientist
{
creating.Int++;
creating.Tou++;
creating.Dex--;
}
ofstream a_file ( "character.cha" );
a_file<<"Character data, do not edit\n";
a_file<<creating.name[256]<<"\n";
a_file<<creating.Race<<"\n";
a_file<<creating.Class<<"\n";
a_file<<creating.Str<<"\n";
a_file<<creating.Int<<"\n";
a_file<<creating.Dex<<"\n";
a_file<<creating.Tou<<"\n";
a_file<<creating.Sen<<"\n";
a_file<<creating.HP<<"\n";
a_file<<creating.SP<<"\n";
a_file<<"End of file";
a_file.close;
cout<<"Creating complete!";
}
char.h contains this:
#include <cstdlib>
using namespace std;
class character
{
public:
char name[256];
int Race;
char Class;