解决 "expression must have pointer to class type" 错误

Solving a "expression must have pointer to class type" error

class testClass { public: int B, C; };

testClass u;
testClass * k = &u;
testClass ** m = &k;

*m->B = 1;//Error appears here

我想我已经正确地遵循了指针引用的规则。我仍然不知道为什么会这样。有人可以帮助我吗?

operator->precedence 高于 operator*,因此 *m->B 等同于 *(m->B);而 m->B 在这里无效。

您应该将其更改为 (*m)->B