Advertisement
Dprogrammed1

cplus

Apr 1st, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.     using namespace std;
  3.     class Testpm
  4.     {
  5.         public:
  6.         void m_func1()
  7.         {
  8.             cout << "func1\n";
  9.         }
  10.         int m_num;
  11.     };
  12.     void (Testpm :: *pmfn)() = &Testpm :: m_func1;
  13.     int Testpm :: *pmd = &Testpm :: m_num;
  14.     int main()
  15.     {
  16.         Testpm ATestpm;
  17.         Testpm *pTestpm = new Testpm;
  18.         (ATestpm.*pmfn)();
  19.         (pTestpm ->* pmfn)();
  20.         ATestpm.*pmd = 1;
  21.         pTestpm ->* pmd = 2;
  22.         cout << ATestpm.*pmd << endl
  23.         << pTestpm ->* pmd << endl;
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement