Hello.
Q1: I want to create a creature "dog" with id=1, and a creature "cat" with id=2, using the following class
How can I store the instances in a file "creature.dat" and how can I read the stored information from the file?
If I include private data member in the class, will that change anything?
1 2 3 4 5 6 7 8 9 10 11 12
|
class Creature
{
public:
int m_Name;
int m_id;
void Greet();
};
void Critter::Greet() // member function definition
{
cout << "Hi. I'm a creature. My name is " << m_Name << ".\n";
}
|
Q2: The above example is a simple one because right now I just want to know how the "save" part works. The goal is to create a wrestling simulator.
From what I've heard vectors are used when the type of the values are of the same type (int,char,..). However, for the wrestlers I will need different types since they will have name, level, experience points,... Is a class the best way to group all the information that define a wrestler, or do you propose some other way?
PS: Sorry for my English and thanks.