Hi,
I'm wondering if there is an automated way to write instances of classes to a disk and read instances of classes from a disk. Does something like sizeof(instanceOfClass) give the actual size of a complete instance of an object?
If so, could fread and fwrite be used directly? i.e. fwrite(&instanceOfClass,1,sizeof(instanceOfClass),outp);
fread(&instanceOfClass,1,sizeof(instanceOfClass),inp);
Sean
What is a POD type?
Would standard c++ containers such as map, multimap, vector, set, list, etc... fall into the POD category?
I didn't write the code for those, so I'm not sure if they have pointers or not.
Sean
any complex class with private members is probably not a POD type.
POD types are basic types like int, char, etc... and simple structs consisting of only POD types:
1 2 3 4 5 6 7 8 9 10 11
struct example
{
int foo;
int bar;
}; // this struct will be a POD type
struct example2
{
int foo;
std::string bar;
}; // this is NOT a POD type because std::string is not a POD
(note the technical difference between POD and non-POD are slightly different, but the above is a good "rule of thumb" to go by).