Eigenpoll : D wish list : Against class instance sizeof
Sizeof for class instances is needed if you save them to files as binary images, or move them around in arrays of instances. Such activity is dangerous, risks creation of copies of instances, and generally is not for "regular programmers" at all.
Instances also contain pointers which of course become invalid after reload from file to next invocation of program (and why would you ever reload them to the original invocation).
People who cannot themselves invent the following, should not use Sizeof on classes:
class SomeClass {
public:
int var1, var2, var3;
int byteSize()
{
return
var3.offsetof + var3.sizeof;
}
}
Ordinary programmers needing to "save an instance" should (for example) create methods for the class to save the data of an instance, and to create an instance from such data.
Report this item for cleanup