Question: As is the case with many students trying to learn c++ I'm a little confused about pointers and in particular pointers to objects.

A simple pointer such as 

```
int *x = new int(5);

```

is easy to understand because x simply stores the address of a word that stores the int 5.

But what if we have something like 

```
 MyClass *x = new MyClass();

```

In this case x can't point to a word containing an instance of MyClass since it could be larger than a word. 

So the question is what does an object pointer actually point to in memory?

Answer: 
In the case of objects, just like an array, it points to the first element contained within the data structure. Pointers can only point to one address in memory. They do not store any more information than this value. What makes them look like you can point to larger types is just the compiler at work. Actually, it stands even for ints which takes 4 bytes in memory. An int pointer will only point to the first byte of said data structure and the compiler will take care of loading the right amount of memory when needed based on the result of the `sizeof(T)` operator.

For instance, `sizeof(int)` returns 4 which is the amount of bytes in memory required to store the entire value of an int. If you create a pointer to an int, it will refer to the first of those 4 bytes using a 32 or 64 bit-long address depending on your target processor asuming an x86 architecture. If an object MyClass contains 3 ints and 1 double, the `sizeof(MyClass)` operator will return 20 `(3 * 4 + 8)`. Again, a pointer to MyClass will only point to the first byte using a 32 or 64 bit address.

The size of pointers stays the same across an entire CPU architecture. If your CPU can allocate 8 bits of memory, your pointers will be a single byte long. In other words, `sizeof(T*) == sizeof(unsigned char)`. On an x86\_64 target architecture, the size of a pointer will 64 bit in length thus `sizeof(T*) == sizeof(long long)`.
```
MyClass *x = new MyClass();

```

In this case, x will store the address of a memory block that is `sizeof(MyClass)` in length.

Another use:

```
Myclass *y = new (0x11111122) MyClass();

```

In this case, y will store 0x11111122, which is an address where a new MyClass instance has been initialized (This example will most probably crash your application, as you are probably corrupting whatever is in memory at this address).