Lecture overview -- Keyboard shortcut: 'u'  Previous page: What about prevention of derivation in C++ -- Keyboard shortcut: 'p'  Next page: Multiple inheritance - issues and C++ solutions -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 4 - Page 12 : 24
Notes about C++
Abstraction Mechanisms, Part 2
Pointer to members

A pointer to a member function corresponds to a function pointer

Useful for activation of an unknown/arbitray method among several possible of the same signature

The two special C++ operators   .*  and   ->*   bind a pointer to member to a specific object (accessed without or via a pointer respectively)

  • The C++ Programming Language: Page 418, 853
 

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/pointer-to-member/point.hClass variant of class Point with several different move functions.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/pointer-to-member/point.ccImplementation of class Point and the tree move methods - not important for the example.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/pointer-to-member/prog.ccA program that illustrates pointer to Point member functions.


It is also possible to estabslish a pointer to a data member

The notation associated with pointers to members is a challenge, at least at first sight