G
G-Factor
Hi all
I've just started learning about saving files. I got bit of a problem. The
following code gives me an error about incompatible types. (Cannot covert
from class character to char *). I would appreciate it if anyone could
either help me out, or direct me to an online resource site that has
information on saving/loading classes. I have found several tutorials, but
they either do not really help (saving text files) or are too difficult for
me to understand. Thanks
class character
{
public:
character();
character(string charName);
virtual ~character();
string getCharName();
private:
string name;
int age;
};
void saveFile(character* characterFile)
{
ofstream writeFile;
writeFile.open("game.dat", ios::binary);
writeFile.write((char *)characterFile, sizeof(character));
writeFile.close();
}
I've just started learning about saving files. I got bit of a problem. The
following code gives me an error about incompatible types. (Cannot covert
from class character to char *). I would appreciate it if anyone could
either help me out, or direct me to an online resource site that has
information on saving/loading classes. I have found several tutorials, but
they either do not really help (saving text files) or are too difficult for
me to understand. Thanks
class character
{
public:
character();
character(string charName);
virtual ~character();
string getCharName();
private:
string name;
int age;
};
void saveFile(character* characterFile)
{
ofstream writeFile;
writeFile.open("game.dat", ios::binary);
writeFile.write((char *)characterFile, sizeof(character));
writeFile.close();
}