P
Pep
I'm getting weird results at the moment so thought I'd rebase my
knowledge of c++ storage with your help
I have a class used as a type in a struct and the struct is handled by
a 3rd party binary writed for persistent storage. I am confused by the
results I am getting and am not sure how the 3rd party writer is
seeing the size of the stuct.
class foo
// I have not included the methods for brevity
{
public:
unsigned short shortArray[4];
};
typedef struct
{
foo fooVar;
char charArray[8];
} bar;
So if you do a sizeof(foo) you get back 8 as a result and a
sizeof(bar) returns 16. However the class foo has methods as well. Now
if I was to do any form of binary copy on bar such as using memcpy for
example using the sizeof(bar) as the length, will I definitely be
copying the complete data in bar or will the operation be thrown out
by things like internal members in foo created by the compiler, like
the vtbl in foo?
TIA
knowledge of c++ storage with your help
I have a class used as a type in a struct and the struct is handled by
a 3rd party binary writed for persistent storage. I am confused by the
results I am getting and am not sure how the 3rd party writer is
seeing the size of the stuct.
class foo
// I have not included the methods for brevity
{
public:
unsigned short shortArray[4];
};
typedef struct
{
foo fooVar;
char charArray[8];
} bar;
So if you do a sizeof(foo) you get back 8 as a result and a
sizeof(bar) returns 16. However the class foo has methods as well. Now
if I was to do any form of binary copy on bar such as using memcpy for
example using the sizeof(bar) as the length, will I definitely be
copying the complete data in bar or will the operation be thrown out
by things like internal members in foo created by the compiler, like
the vtbl in foo?
TIA