Reputation: 3927
#define SYNC_DATA_CB list<string> (*syncData)(void)
I want to have in my class a member (static or not is not matter) that will hold the reference to the function pointer.
I tried to declare like this, but didnt compiled:
SyncProcess{
public:
SyncProcess(SYNC_DATA_CB);
static SYNC_DATA_CB sync_cb_;
}
Upvotes: 0
Views: 64
Reputation: 9089
Use typedef instead of macro:
class SyncProcess
{
public:
// Typedef to create function pointer alias SyncDataFunc
typedef list<string>(*SyncDataFunc)();
// Use alias as input parameter type
SyncProcess(SyncDataFunc func);
// Use alias as static member type
static SyncDataFunc sync_cb_;
};
Upvotes: 0
Reputation: 426
I think what you might be looking for is a typedef instead.
typedef list<string>(*syncData)(void);
class SyncProcess{
public:
SyncProcess( syncData );
static syncData sync_cb_;
};
Upvotes: 1