L
LinusLee
class CAnalyzer
{
// attribute
private:
public:
// behavior
private:
void NullFunc(NODE *pNode);
void TraverseNode(NODE* pNode, void (*preFunc)(NODE *node), void
(*postFunc)(NODE *node));
public:
void BuildSymbolTbl(NODE *pRootNode);
void CheckType(NODE *pRootNode);
// debug
void PrintNode(NODE *pNode);
};
I defined CAnalyzer class like this...
I want to get PrintNode and NullFunc function pointer and put this to
TraverseNode args...
I just described to get function pointer like this...
void CAnalyzer::BuildSymbolTbl(NODE *pSyntaxTree)
{
typedef void (CAnalyzer::*pPrintNode)(NODE *pNode);
typedef void (CAnalyzer::*pNullFunc)(NODE *pNode);
pPrintNode t = &CAnalyzer:rintNode;
pNullFunc t2 = &CAnalyzer::NullFunc;
TraverseNode(pSyntaxTree, t, t2);
}
then... when I compile this code, compiler inform me this error msg.
error C2664: 'TraverseNode' : cannot convert parameter 2 from 'void
(__thiscall CAnalyzer::*)(union tagNodeType *)' to 'void (__cdecl
*)(union tagNodeType *)'
There is no context in which this conversion is possible
I know that member function in class is type of (__cdecl*)...
and (CAnalzer::*pPrintNode) is __thiscall*...
how can I get the correct member function pointers...
{
// attribute
private:
public:
// behavior
private:
void NullFunc(NODE *pNode);
void TraverseNode(NODE* pNode, void (*preFunc)(NODE *node), void
(*postFunc)(NODE *node));
public:
void BuildSymbolTbl(NODE *pRootNode);
void CheckType(NODE *pRootNode);
// debug
void PrintNode(NODE *pNode);
};
I defined CAnalyzer class like this...
I want to get PrintNode and NullFunc function pointer and put this to
TraverseNode args...
I just described to get function pointer like this...
void CAnalyzer::BuildSymbolTbl(NODE *pSyntaxTree)
{
typedef void (CAnalyzer::*pPrintNode)(NODE *pNode);
typedef void (CAnalyzer::*pNullFunc)(NODE *pNode);
pPrintNode t = &CAnalyzer:rintNode;
pNullFunc t2 = &CAnalyzer::NullFunc;
TraverseNode(pSyntaxTree, t, t2);
}
then... when I compile this code, compiler inform me this error msg.
error C2664: 'TraverseNode' : cannot convert parameter 2 from 'void
(__thiscall CAnalyzer::*)(union tagNodeType *)' to 'void (__cdecl
*)(union tagNodeType *)'
There is no context in which this conversion is possible
I know that member function in class is type of (__cdecl*)...
and (CAnalzer::*pPrintNode) is __thiscall*...
how can I get the correct member function pointers...