I have database project that I want to move from C to C++. In this C project I have lots of small packed structs, that I write directly to file or read from mmaped file - e.g. directly from memory address.
I need the class in-memory representation, to be exactlybthe same as if I use plain old C struct. I believe this is called POD or C++ standard layout.
I can proceed in several ways:
I can do class, bu I worry that if I add methods to this struct, probably the internal structure will be changed.
If I wrap the a structure into class, I will need to create / destroy classes all the time, along with the structs.
If I do it C - OO style, I will need to supply pointer to every function, e.g.
static const char *Pair::getKey(const void *mem);
I can also make the struct a field and do something similar
void Pair::setMem(const void *mem);
const char *Pair::getKey();
but the more I see this, the less I like it, because there is no real advantage.
Anything I am missing?