CPP/FunctionPointer

From ProgrammingExamples
< CPP
Revision as of 08:16, 23 June 2010 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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);
}