#include
#include
using namespace std;
// delegate_pointer.cpp
// declaring some method
void method_1(string text);
void pointer_delegate(string text, void (*point_or_delegate)(string text));
int main()
{
//call here giving a text argument
pointer_delegate("Calling method_1 Roger : ", method_1);
return 0;
}
//working with the methods
void method_1(string text)
{
// a method that will print
cout << text << endl;
cout << "Processed Your Call" << endl ;
}
//creating a plointer to the method that will have pointer to the method
//encapsulate the method that will have a pointer *
void pointer_delegate(string text, void (*point_or_delegate)(string))
{
// processing the input
(*point_or_delegate)(text);
}
|