How to Create a Function Point for a class member function.

M

Microsoft

Hi;

I want to create a function point.With is point I can call the member
function in a class. The Sample Code just like:

__gc struct NodeMapItem
{
String *NodeID;
void (*FuncPnt)(reportNode *);
};

__gc class CReportManager
{
public:
CReportManager(void);
~CReportManager(void);
private:
public:
void DspRpt(TreeNode *pNode);
void Load_JH_HZ_001(reportNode *pNode);
};

////in .cpp file
void CReportManager::Load_JH_HZ_001(reportNode *pNode);
{
......
}
void CReportManager::DspRpt(TreeNode *pNode)
{
reportNode *pSltNode;
pSltNode= dynamic_cast<reportNode*>(pNode);

RptMapFunc=new NodeMapItem*[2];
RptMapFunc[0]=new NodeMapItem;

RptMapFunc[0]->FuncPntLoad_JH_HZ_001;->there is some error:C2440
//RptMapFunc[0]->FuncPnt=&CReportManager::Load_JH_HZ_001;-> there is some
error too.


if (!pSltNode->m_pNodeType->CompareTo(REPORT))
{
pDspView=RptMapFunc[0]->FuncPnt;
pDspView(pSltNode);
}

}

I do not know how to define point type.Some ont told me I should define a
Class Fundction Point,but how to do that?

Please help me!By the way my develop tools is .Net 2003 and os is Window
2000 perfessional;


Thanx

David

2004-8-12
 
T

Tomas Restrepo \(MVP\)

David,
I want to create a function point.With is point I can call the member
function in a class. The Sample Code just like:

__gc struct NodeMapItem
{
String *NodeID;
void (*FuncPnt)(reportNode *);
};

__gc class CReportManager
{
public:
CReportManager(void);
~CReportManager(void);
private:
public:
void DspRpt(TreeNode *pNode);
void Load_JH_HZ_001(reportNode *pNode);
};

////in .cpp file
void CReportManager::Load_JH_HZ_001(reportNode *pNode);
{
.....
}
void CReportManager::DspRpt(TreeNode *pNode)
{
reportNode *pSltNode;
pSltNode= dynamic_cast<reportNode*>(pNode);

RptMapFunc=new NodeMapItem*[2];
RptMapFunc[0]=new NodeMapItem;

RptMapFunc[0]->FuncPntLoad_JH_HZ_001;->there is some error:C2440
//RptMapFunc[0]->FuncPnt=&CReportManager::Load_JH_HZ_001;-> there is some
error too.


if (!pSltNode->m_pNodeType->CompareTo(REPORT))
{
pDspView=RptMapFunc[0]->FuncPnt;
pDspView(pSltNode);
}

}

I do not know how to define point type.Some ont told me I should define a
Class Fundction Point,but how to do that?

You'd using managed code, so you'd be much better off using a Delegate
instead of a function pointer here. Look at the docs for the __delegate
keyword for a few examples.
 
M

Microsoft

Hi Tomas£º

Thanx for your suggestion.I had gotten the solution with the "
__delegate".

David

2004-08-13


Tomas Restrepo (MVP) said:
David,
I want to create a function point.With is point I can call the member
function in a class. The Sample Code just like:

__gc struct NodeMapItem
{
String *NodeID;
void (*FuncPnt)(reportNode *);
};

__gc class CReportManager
{
public:
CReportManager(void);
~CReportManager(void);
private:
public:
void DspRpt(TreeNode *pNode);
void Load_JH_HZ_001(reportNode *pNode);
};

////in .cpp file
void CReportManager::Load_JH_HZ_001(reportNode *pNode);
{
.....
}
void CReportManager::DspRpt(TreeNode *pNode)
{
reportNode *pSltNode;
pSltNode= dynamic_cast<reportNode*>(pNode);

RptMapFunc=new NodeMapItem*[2];
RptMapFunc[0]=new NodeMapItem;

RptMapFunc[0]->FuncPntLoad_JH_HZ_001;->there is some error:C2440
//RptMapFunc[0]->FuncPnt=&CReportManager::Load_JH_HZ_001;-> there is some
error too.


if (!pSltNode->m_pNodeType->CompareTo(REPORT))
{
pDspView=RptMapFunc[0]->FuncPnt;
pDspView(pSltNode);
}

}

I do not know how to define point type.Some ont told me I should define a
Class Fundction Point,but how to do that?

You'd using managed code, so you'd be much better off using a Delegate
instead of a function pointer here. Look at the docs for the __delegate
keyword for a few examples.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top