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:
Ddigit2006-07-18 16:31
You also forgot to return 0 at the end of main.
Also, it's better to pass the character object as an argument to the function stat instead of relying on that the object stil exists within the stat scope.
Example on how to share data between classes:
#include <iostream>
using namespace std;
class Cnum{
private:
int a;
public:
void set(int i){a = i;};
int get(){return a;};
};
int main(){
Cnum no_one;
Cnum no_two;
no_one.set(10) //sets the int a to 10 inside the object no_one
no_two.set(no_one.get());// sets no_two's a to no_one's a.
cout<<no_two.get()<<endl;
return 0;
}
This way makes sure that you dont access your class varibles by accident.
Name:
Ddigit2006-07-18 16:55
You also forgot to return 0 at the end of main.
Also, it's better to pass the character object as an argument to the function stat instead of relying on that the object stil exists within the stat scope.
Example on how to share data between classes:
#include <iostream>
using namespace std;
class Cnum{
private:
int a;
public:
void set(int i){a = i;};
int get(){return a;};
};
int main(){
Cnum no_one;
Cnum no_two;
no_one.set(10) //sets the int a to 10 inside the object no_one
no_two.set(no_one.get());// sets no_two's a to no_one's a.
cout<<no_two.get()<<endl;
return 0;
}
This way makes sure that you dont access your class varibles by accident.