From what I understand, pointers hold the addresses of a value, and references can be thought as const
pointers.
From this sample code:
int main() {
int i = 1;
int &ri = i;
int *pi = &i;
return 0;
}
The disassembly, both pointer and reference look exactly the same:
main:
push ebp
mov ebp, esp
sub esp, 16
mov DWORD PTR [ebp-12], 1
lea eax, [ebp-12]
mov DWORD PTR [ebp-8], eax
lea eax, [ebp-12]
mov DWORD PTR [ebp-4], eax
mov eax, 0
leave
ret
Are pointers and references only enforced by the compiler?