Difference between revisions of "CPP/FunctionPointer"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(Created page with '==FunctionPointer.cpp== <source lang="cpp"> #include <iostream> using namespace std; void add(int a, int b); void DoThing(void (*pt2Func)(int,int)); int main(int argc, char …')
(No difference)

Revision as of 08:16, 23 June 2010

FunctionPointer.cpp

#include <iostream>
 
using namespace std;
 
void add(int a, int b);
void DoThing(void (*pt2Func)(int,int));
 
int main(int argc, char *argv[])
{
  DoThing(add);
 
  return 0;
}
 
void add(int a, int b)
{
  cout << a+b;
}
 
void DoThing(void (*pt2Func)(int,int))
{
  pt2Func(2,3);
}