I am trying to save my program settings to disk but I cannot cast the data (a char*) to my class called Settings. This is done easily in C#, how do I do it in C++?
Printable View
I am trying to save my program settings to disk but I cannot cast the data (a char*) to my class called Settings. This is done easily in C#, how do I do it in C++?
I have to stop thinking with a C# mentality. I wasn't casting it to a pointer!
Direct serialization of class objects in C++ is highly complex and best avoided. Use alternative serialization. Save the data from the Settings class to a .ini, .properties or .xml, anything.
Is this ok?
Code:class Settings
{
public:
BYTE brStyle0_1_2;
BYTE spAssignOp0_1_2;
bool spFuncsAndStructs;
bool spSemiColins;
bool spOperators;
bool replNullWZero;
bool spCommas;
Settings()
{
this->brStyle0_1_2= 2;
this->spAssignOp0_1_2= 1;
this->spFuncsAndStructs= 0;
this->spSemiColins= 1;
this->spOperators= 1;
this->spCommas= 1;
this->replNullWZero= 1;
}
};