O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

21.6. Pointers to Class Members (.* and ->*)

C++ provides the .* and ->* operators for accessing class members via pointers. This is a rarely used capability, primarily for advanced C++ programmers. We provide only a mechanical example of using pointers to class members here. Figure 21.6 demonstrates the pointer-to-class-member operators.

 1   // Fig. 21.6: fig21_06.cpp 2   // Demonstrating operators .* and ->*. 3   #include <iostream> 4   using namespace std; 5  6   // class Test definition 7   class Test 8   { 9   public:10      void func()11      {12         cout << "In func\n";13      } // end function func14 15      int value; // public data member16   }; // end class Test17 18   void arrowStar( Test * ); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required