| Type: |
|
| Level: |
Expert
|
| Date: |
2006-Dec-08
|
| Visited: |
1054 times
|
| Rating: |

|
| Author: |
Alex Plumpton |
|
|
C ++ allows you to generate a special type of pointer that points to a member of a class, not to a specific instance of that member in an object. This sort of pointer is called a pointer to a class member or pointer-to-member. The figure shown, illustrates the usage of pointer to members.
Pointers To Members
int stud :: *info =&stud::id;
The info pointer, thus created, acts like a class member in that it must be invoked with a class object. In the statement, the phrase stud::' means "pointer- to —member ofstutl class". The phrase &stud:: id means the "address ofthe id member of stud class". The pointer info can now be used to access the memberid inside member functions.