+ 1
How to Dereference object?
normally, int x = 5; int *p = &x; p = address of x *p = x = 5 in oop : SomeClass obj; obj.func(); SomeClass *p = &obj; so now we have to use, p->func(); but if I try, *p.func(); [*p should be Dereferenced and should work as obj] this gives an error. why does this happen
2 ответов
+ 3
This may be because the member access operator is evaluated before the dereference operator. Try (*p).func()
+ 1
Thanks! It worked.