I want to store class member function address, to local data structure(table)
typedef struct
{
unsigned int id;
void (TCLASS::*proc)();
} TSTRUCT;
class TCLASS{
public:
void tfunct();
const TSTRUCT t1 = { 1, &tfunct};
};
I want to store class member function address, to local data structure(table)
typedef struct
{
unsigned int id;
void (TCLASS::*proc)();
} TSTRUCT;
class TCLASS{
public:
void tfunct();
const TSTRUCT t1 = { 1, &tfunct};
};
Though you didn't write a question, assuming you are facing bunch of compiler errors.
See below :
class TCLASS ; //forward declaration
struct TSTRUCT
{
unsigned int id;
void (TCLASS::*proc)( );
// // Use the TSTRUCT constructor
TSTRUCT(int i, void (TCLASS::*fptr)( ) ): id(i), proc(fptr)
{
}
} ;
class TCLASS{
public:
void tfunct();
TCLASS() : t1(1, &TCLASS::tfunct ) // initialize the const member
//~~~~~~~~~~~^ Use &TCLASS::tfunct instead of &tfunct
{
}
const TSTRUCT t1;
};