Callback in c++ - Could not understand
<p>I tried to understand how call back works...In the below program passing the <code>(void*)&amp;obj</code> and receiving it in <code>(void* pt2Object)</code> is confusing me... <code>*pt2Object</code> will hold the value and not the address of some variable but here the reference is paased to it..
I could not understand how the <code>ClassA::Wrapper_To_Call_Display</code> func is passed and get accepted in <code>void (*pt2Function)(void* pt2Object,char* text))</code>...
Please help me to understand about it..</p>

<pre><code>//---Program To use Function Pointers As A CallBack---

#include "stdafx.h"
#include &lt;iostream&gt;
using namespace std;

class ClassA
{
public:
  void Display(const char* text)
  {
    cout&lt;&lt;text&lt;&lt;endl;
  }
  static void Wrapper_To_Call_Display(void *pt2Object,char* text);
};
void ClassA::Wrapper_To_Call_Display(void *pt2Object,char* text)
{
  ClassA* myself = (ClassA*)pt2Object;
  myself-&gt;Display("string");
  cout&lt;&lt;text&lt;&lt;endl;
}
void DoIt(void* pt2Object, void(*pt2Function)(void* pt2Object, char* text)) {
  pt2Function(pt2Object, "Hi I am Calling back using an argument!!");
}
void Callback_Using_Argument() {
  ClassA obj;
DoIt((void*)&amp;obj,ClassA::Wrapper_To_Call_Display);
}
int main() {
  Callback_Using_Argument();
  return 0;
}
</code></pre>

<h2>output</h2>

<pre><code>string
Hi I am Calling back using an argument!!
Press any key to continue . . .
</code></pre>
