Size of memory allocation for pointers

I am slowly starting to really get a grasp on pointers, but I am quite confused on how the memory allocation of pointers is beneficial:

- On most compilers, a pointer is either 4 bytes or 8 bytes. In contrast to this, it is known that pointers, while taking up space in memory, take up much less space than the data types they point to. If this is the case, how can a pointer of size 4 or 8 bytes ever take up less space than the data type it points to (int - 4 bytes, char - 1 byte, etc.)?

(I understand that pointers are most useful when dealing with dynamic memory allocation, but I am just interested in the size of memory, not the use of that memory right now)
A pointer is a variable that contains a memory address. That is all it contains. It does not contain the data at the memory address that it represents, much like an address book doesn't contain all of the houses for which it stores addresses.
I understand that.

My question is more focused on the size of the pointer itself inside of the memory.
For example,
1
2
3
4
5
struct VeryBigObject{
    char big_array[1024 * 1024 * 1024];
};

VeryBigObject *pointer = new VeryBigObject;
sizeof(VeryBigObject) = 1 GiB, sizeof(VeryBigObject *) = 4 or 8 bytes.
I've never thought of it this way, it makes total sense now. Thanks!
Topic archived. No new replies allowed.