While I don't know C++, I do know that C uses
the Following statement to construct Function Pointers.

(*FuncPnt) ('Insert arguments here.')

I've only seen this used in function arguments, but I
guess that they can be a variable too.

--- On Wed, 8/18/10, .Aikilis <[email protected]> wrote:

From: .Aikilis <[email protected]>
Subject: [c-prog] How to get the address of functions in the struct?
To: "C-Prog邮件讨论组[英文]" <[email protected]>
Date: Wednesday, August 18, 2010, 3:47 AM







 



  


    
      
      
      

I'm using MS VC++ 6.

We all know how to get the addres of a usual function:



//funcadd1.cpp



#include <iostream.h>



int Function() {return 0;}



void main()



{



cout<<Function<<endl;



}



But I don't know how to get the addres of a function in the struct.



I tried methods below but all failed.



struct TS



{



int Data;



int Run();



};



int TS::Run() {return 0;}



//Method 1:



cout<<TS::Run<<endl;



//Method 2:



cout<<(int)(TS::Run)<<endl;



//Method 3:



TS tsX;



cout<<tsX.Run<<endl;



//Method 4:



TS tsX;



cout<<(int)(tsX.Run)<<endl;



Thanks for any suggestions.



                                          



[Non-text portions of this message have been removed]





    
     

    
    


 



  






      

[Non-text portions of this message have been removed]

Reply via email to