title: Calling member function of one class from another
body: <p>I have this problem with a big piece of code which have some event handling objects. In an event handling class I am trying to call a function of another class through pointer but it is having same error as this code have which I have implemented to just check the logic that I am using to call there. What is wrong I am doing here?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  class FunctionPointer;
  class UseFP
  {
  public:
      UseFP(void){}
      ~UseFP(void){}
  
      void Modified(int m,int n);
      void (FunctionPointer::*update)(int,int);
  
  };
  
  void UseFP::Modified(int m,int n)
      {
              //(this-&gt;*update)(m,n);// call by fp if I uncomment it it gives error.
      }
  
  class FunctionPointer
  {
      int a,b;
      UseFP * obj;
  public:
      FunctionPointer(void);
  
      ~FunctionPointer(void);
  
      void updateData(int m, int n)
      {
          a = m;
          b = n;
          cout&lt;&lt;"\n\nUpdated: a "&lt;&lt;a&lt;&lt;", b "&lt;&lt;b&lt;&lt;endl;
      }
  
      void Input()
      {
          int m, n;
          cout&lt;&lt;"\nEnter new data: ";
          cin&gt;&gt;m&gt;&gt;n;
          obj-&gt;Modified(m,n);
      }
      };
  
  void main()
  {
      FunctionPointer obj;
      obj.Input();
  }
  </code></pre>
  
  <p>errors after uncommenting function call</p>
  
  <pre><code>1&gt;------ Build started: Project: FunctionPointer, Configuration: Debug Win32 ------
  1&gt;Compiling...
  1&gt;main.cpp
  1&gt;c:\users\volmo\desktop\functionpointer\functionpointer\functionpointer.h(14) : error C2440: 'newline' : cannot convert from 'UseFP *const ' to 'FunctionPointer *const '
  1&gt;        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
  1&gt;c:\users\volmo\desktop\functionpointer\functionpointer\functionpointer.h(14) : error C2647: '-&gt;*' : cannot dereference a 'void (__thiscall FunctionPointer::* )(int,int)' on a 'UseFP *const '
  1&gt;Generating Code...
  1&gt;Compiling...
  1&gt;FunctionPointer.cpp
  1&gt;c:\users\volmo\desktop\functionpointer\functionpointer\functionpointer.h(14) : error C2440: 'newline' : cannot convert from 'UseFP *const ' to 'FunctionPointer *const '
  1&gt;        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
  1&gt;c:\users\volmo\desktop\functionpointer\functionpointer\functionpointer.h(14) : error C2647: '-&gt;*' : cannot dereference a 'void (__thiscall FunctionPointer::* )(int,int)' on a 'UseFP *const '
  1&gt;Generating Code...
  1&gt;Build log was saved at "file://c:\Users\volmo\Desktop\FunctionPointer\FunctionPointer\Debug\BuildLog.htm"
  1&gt;FunctionPointer - 4 error(s), 0 warning(s)
      ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>