Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get the address of a function?

Status
Not open for further replies.

sulacco

Technical User
Nov 8, 2002
74
RU
I've got this function. How can I get the address of OnClose()? in one of my variables.
...

void CMainFrame::OnClose()
{
int *ogre=&OnClose(); //this is just don't work

}
 
A pointer to a function is just it's name (just like a pointer to the start of an array is just the name of the array).

So in your example.
Code:
int *ogre=OnClose;

However, function pointers also have types (your example is wrong in this respect).

It would be more like
Code:
void (CMainFrame::*ogre)(void) = OnClose;

For much more information on this aspect, read this.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top