From what I've read so far, it seems that reference variables are not supposed to take any memory at all. Instead they are treated as the exact same variable they are referencing but with another name.
However, when I ran the following code, it seems that it is not always the case:
#include <cstdio>
struct A
{
int m[3];
};
struct B: A
{
B():x(m[0]), y(m[1]), z(m[2]){}
int& x;
int& y;
int& z;
};
int main(){
printf("%u, %u\n", sizeof(A), sizeof(B));
return 0;
}
Output:
12, 40
Why is B so much bigger than A?
Is there any other way I can access, for example, B.m[0] with B.x?