M
mlamb1
I have some code that works it seems a bit of a hack. I want to know
if there is a more c++y way to do it.
Here's my code:-
class CMyClass{
public:
void Save(CFile fOut);
void Load(CFile fOut);
char *mPointerIDoNotWantTosave;
char *mAnotherPointerIDoNotWantTosave;
....
//start of data i want to save
int mDataStart;
....
int mDataEnd;
} ;
CMyClass::Save(CFile fOut)
{
int dataSize = (char *)mDataEnd - (char *)mDataStart) +
sizeof(mDataEnd);
fOut.Write(&mDataStart, dataSize);
}
I guess I could make my Save and Load functions write each member
individually, but that seems pretty tedious and makes changing the
class a pain. Is there a better way?
if there is a more c++y way to do it.
Here's my code:-
class CMyClass{
public:
void Save(CFile fOut);
void Load(CFile fOut);
char *mPointerIDoNotWantTosave;
char *mAnotherPointerIDoNotWantTosave;
....
//start of data i want to save
int mDataStart;
....
int mDataEnd;
} ;
CMyClass::Save(CFile fOut)
{
int dataSize = (char *)mDataEnd - (char *)mDataStart) +
sizeof(mDataEnd);
fOut.Write(&mDataStart, dataSize);
}
I guess I could make my Save and Load functions write each member
individually, but that seems pretty tedious and makes changing the
class a pain. Is there a better way?