Reputation: 403
class testClass { public: int B, C; };
testClass u;
testClass * k = &u;
testClass ** m = &k;
*m->B = 1;//Error appears here
I think I've followed the rules of pointer referencing correctly. I still have no idea why this is happening. Could someone help me?
Upvotes: 4
Views: 3266
Reputation: 172964
operator->
has higher precedence than operator*
, so *m->B
is equivalent as *(m->B)
; while m->B
is not valid here.
You should change it to (*m)->B
.
Upvotes: 9