Why -> and not *name.type

When you are coding with pointers in c++ and you want to access the function/variable from that pointer deferenced, how come you cannot use something like below.

struct typeT{
   int value1;
typeT* tt = new typeT;

it is because the access element of the variable tt is higher in the compiler and thus it tries to equate


first, which is not a good thing because the tt has not been de-referenced and thus it is just a memory address pointer to the actual object. so you need to do


because like in maths the () will be equated first and then the access element part “.” and thus to make it easier


will change to


within the compiler.

Leave a Reply

Your email address will not be published. Required fields are marked *