A little confusion

hello sir, actually i am a bit confused between when to use this( . ) as a pointer and when to use this(->) , as in what are the differences in the implementation of both the pointers, please give me some clarity…

hello @we_kaash

we use (.) dot with object.

we use -> operator when we have pointer of object.

for example->

ClassName   obj=ClassName();

here obj is object so use dot(.) operator to access its member variable or function.


ClassName  objPtr=new ClassName();
here objPtr is pointer that contains address of pointer so in this case u should use -> operator to access object member variable or its function.
1 Like