CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Location
    India
    Posts
    4

    Function Pointer from a string

    Hi all,

    I am looking for a solution in c++. I.e. At runtime how I can get
    the function pointers which is existing in the object. Will it be possible to invoke a function dynamically through a string that contains it's(function) name.

    Regards,
    PMS.

  2. #2
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    The best solution I can think of is to have a method within the class that maps a string to a function, and have it called through there.

    Jeff

  3. #3
    Join Date
    Jan 2000
    Location
    tamilnadu,india
    Posts
    3
    The details regarding where a function is stored is not available in an object always. When a class contains no virtual fns, the address resolution of the functions happen at compile time and i dont think you have an API to access that.
    The scenario is different when there are virtual fns in a class. Every object contains a pointer to the virtual function table. The address of the function to be called is calculated at run time in an implementaion dependent way. you might try out on your implementation how it is actually done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured