0
Size of pointer and Size of a structure
What is the size of a pointer and why? Also, why do we need to assign a type to a pointer? Further, what is the size of a structure?
1 Odpowiedź
+ 2
The size of a pointer depends on the architecture of the machine, for example on x32 systems a pointer is 4 bytes, while on x64 a pointer is 8 bytes.
You can have void pointers, but to dereference them they need to have a type so that the compiler knows the type and size of the variable.
The size of a structure depends on the size of the variables it contains and the vtable pointer if it has one, along with byte packing for memory alignment requirements.