class B {
};
class A {
A(B& b):_b(b)
B& _b;
};
int main() {
B b;
A a(b);
char* x = reinterpret_cast<char*>(&a);
}
I'm creating a hash function based on the byte values of the objects. I want to know wether the bytes of object a will hold b or will they hold a reference (pointer)?
As you declared A::_b as a reference, it will "hold" a reference. Thus the object a does not contain the data of b if you examine a byte-wise.
By the way you forgot to use the address-of operator in your cast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With