flotat
April 16th, 1999, 11:23 AM
Hi !
I'm having problem when trying to declare a C++ function pointer.
I declared a structure :
typedef struct
{
char szTypeName[256];
void (*Func)();
}ITEM, *pITEM;
then a function called for example :
void CMyProject::GetDate()
and I'd like to use another function to set data for an item :
void CMyProject::Add( char *szItemName, void (*Func)() )
{
// Add a new data type
pITEM pData = new ITEM();
strcpy(pData->szTypeName,szItemName);
pData->Func = Func;
m_aDataType.Add(pData);
}
The following sample doesn't compile !!!!
ex : Add("DATE",GetDate);
The C++ Compiler causes the following error :
error C2664: 'Add' : cannot convert parameter 2 from 'void (void)' to 'void (__cdecl *)(void)'
Who can help ?
I think it's a basic C problem, but i can't find out why it's incorrect.
Thanks for your help.
I'm having problem when trying to declare a C++ function pointer.
I declared a structure :
typedef struct
{
char szTypeName[256];
void (*Func)();
}ITEM, *pITEM;
then a function called for example :
void CMyProject::GetDate()
and I'd like to use another function to set data for an item :
void CMyProject::Add( char *szItemName, void (*Func)() )
{
// Add a new data type
pITEM pData = new ITEM();
strcpy(pData->szTypeName,szItemName);
pData->Func = Func;
m_aDataType.Add(pData);
}
The following sample doesn't compile !!!!
ex : Add("DATE",GetDate);
The C++ Compiler causes the following error :
error C2664: 'Add' : cannot convert parameter 2 from 'void (void)' to 'void (__cdecl *)(void)'
Who can help ?
I think it's a basic C problem, but i can't find out why it's incorrect.
Thanks for your help.