Pointer to Member Operators: .* and ->*
pm-expression :
cast-expression
pm-expression .***cast-expression
pm-expression -
>***cast-expression
The binary operator .* combines its first operand, which must be an object of class type, with its second operand, which must be a pointer-to-member type.
The binary operator ->
* combines its first operand, which must be a pointer to an object of class type, with its second operand, which must be a pointer-to-member type.
In an expression containing the .* operator, the first operand must be of the class type of the pointer to member specified in the second operand or of a type unambiguously derived from that class.
In an expression containing the ->
* operator, the first operand must be of the type "pointer to the class type" of the type specified in the second operand, or it must be of a type unambiguously derived from that class.
Example
The following example calls the member function designated by pMemberFunc
for the object pointed to by pObject
and passes the parameter of 6
:
// Example of the pointer to member operators
(pObject->*pMemberFunc) (6);