C++成员指针(Pointer-to-member)操作符

本文链接:http://aztack.wang/post/pointer-to-members-in-cpp.html

 

以前写过一篇关于成员指针的博文,其中提到了MFC是如何使用成员指针的...

 

ISO/IEC 14882:2003 page 85: 5.5 Pointer-to-member operators

The pointer-to-member operators -> and . ...

The binary operator .* binds its second operand, which shall be of the type of "pointer to member of T" (where T is a completely-defined class type) to its first operand, which shall be of class T or of a class of which T is an unambiguous and accessible base class. The result is an object or a function of the type specified by the second operand.

成员指针操作符有两个 -> 和 .

“ .* ”是一个二元操作符,它将第二个参数bind到第一个参数上。其中第二个参数应该是一个指向第一个参数类型(T)的成员指针。而第一个参数应该是类型T的对象或是一个“没有歧义且可访问”的base sub-object。 这个操作符的运算结果是一个对象或函数。(注意:“这个操作符的结果”,而不是最终的结果)

“->*”有类似的定义。

If the dynamic type of the object does not contain the member to which the pointer refers, the behavior is undefined

如果对象不包含指针所指向的内容,那么这个操作符的行为是“未定义的”

If the second operand is the null pointer to member value, the behavior is undefined.

如果第二个操作符是null那么这个操作符的行为是“未定义的”

ISO/IEC 14882:2003 page 137: Pointer to member

The "pointer to member" is distinct from the type "pionter", that is, a pointer to member is declared only by the pointer to member declarator syntax, and never by the pointer declarator syntax. There is no "reference-to-member" type in c++.

 

转载于:https://www.cnblogs.com/zhangyz/articles/6203448.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值