Aug 28, 2004 #1 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 }
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 }
Aug 28, 2004 #2 Salem Programmer Apr 29, 2003 2,455 GB 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. http://www.function-pointer.org/ -- Upvote 0 Downvote
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. http://www.function-pointer.org/ --
Aug 28, 2004 Thread starter #3 sulacco Technical User Nov 8, 2002 74 RU this is great, Salem. Thanks a lot. Upvote 0 Downvote