//cTest.h
#ifndef CTEST_H
#define CTEST_H
#include <stdio.h>
class cTest
{
public:
void run(); //called from outside
private:
void foo(int a, int b); //This a function that I want to run
void (cTest::*pFoo)(int a, int b); //This is a function pointer, with the same arguments as the function
}; //cTest
#endif
//cTest.cpp
//Implementation of cTest.h
#include "cTest.h"
// This is the function we're trying to get to
void cTest::foo(int a, int b)
{
printf("%d %d\n",a,b); //Just enough to see if it works
} //foo
//Called from outside
void cTest::run()
{
pFoo = foo; //Point the function pointer to the actual function
pFoo(1,2); //Now try to execute the function
//I've also tried the following:
//pFoo=&cTest::foo;
//cTest::pFoo(1,2);
} //run
// main.cpp
#include "cTest.h"
void main() //program entry
{
cTest TEST;
TEST.run();
} //main