Original Post
I have two classes: CDog and CCat. I want CDog to contain a function pointer to a member function of CCat.
I can't seem to get it to work quite right. Here is my code so far:
CDog.h
CDog.cpp
CCat.h
I get an error saying that m_pRunFunction(); is not a valid function call. I'm pretty sure this code is almost right, but I can't seem to get it perfect. Any advice?
-Mike
[edited by - doctorsixstring on September 30, 2002 12:03:14 PM]
class CDog
{
public:
CDog();
~CDog();
static CCat* sm_pCat;
private:
void LaunchFunction();
void (CCat::*m_pRunFunction)();
};
#include "CDog.h"
#include "CCat.h"
CCat* CDog::sm_pCat = new CCat();
CDog::CDog()
{
m_pRunFunction = CCat::FunctionToPointTo;
}
CDog::~CDog() { /* ... */}
void CDog::LaunchFunction() { m_pRunFunction(); } //error here
class CCat
{
public:
CCat();
~CCat();
void FunctionToPointTo();
private:
};