What is the purpose of the following esoteric C++ operators?
Pointer to member
::*
Bind pointer to member by pointer
->*
Bind pointer to member by reference
.*
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A pointer to a member allows you to have a pointer that is relative to a specific class.
So, let’s say you have a contact class with multiple phone numbers.
The idea is if you have an algorithm that needs to use a phone number but the decision of which phone number should be done outside the algorithm, pointers to member solve the problem:
Now the caller of robocall can decide which type of phonenumber to use:
.*and->*come into play once you have a pointer. So inside robocall, you would do:or: