What's your source? I think it refers to how the objects are represented in memory, but it's the compiler, not the run-time, that deals with access specifiers.
In memory, a class
might look the same as a struct
, but to the compiler they do not.
Also, the two don't have to be equivalent even in memory (much like they are not equivalent for the compiler). The compiler can re-arrange the members, as long as it keeps those with no interleaving access specifiers grouped together. So, in memory,
class Object {
public:
int i1;
int i2;
private:
char i3;
int i4;
};
could theoretically be represented as
struct {
char i3;
int i4;
int i1;
int i2;
}
Note that I'm only talking about the memory layout here. The actual struct
equivalent of your class is:
struct Object {
private:
public:
int i1;
int i2;
private:
char i3;
int i4;
};