<分区>
Possible Duplicate:
what is the difference between (.) dot operator and (->) arrow in c++
我正在尝试学习c++,但我不明白“->”和“.”之间的区别。调用方法时。
例如,我见过类似 class->method() 和 class.method() 的东西。
谢谢。
标签 c++
<分区>
Possible Duplicate:
what is the difference between (.) dot operator and (->) arrow in c++
我正在尝试学习c++,但我不明白“->”和“.”之间的区别。调用方法时。
例如,我见过类似 class->method() 和 class.method() 的东西。
谢谢。
最佳答案
在正常情况下,a->b
等同于(*a).b
。如果 a
是一个指针,->
在访问该元素之前取消引用它。
关于C++ 不同 -> 和 ".",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3463236/