C++成员选择运营商
Possible Duplicate:
What is the difference between the dot (.) operator and -> in C++?
C++ has the following member selection operators: .
and ->
.
What is the main difference between them?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
.
与非指针一起使用,而->
与指针一起使用,以访问成员!.
不能重载,而->
可以重载。.
is used with non-pointers, while->
is used with pointers, to access members!.
cannot be overloaded, while->
can be overloaded.pointer2object->member()
等于
(*pointer2object).member()
我想,这是为了更方便而设计的。
pointer2object->member()
is equal to
(*pointer2object).member()
and is made for more convinience, as I suppose.