CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    3

    Alternative to Function Pointers in Java

    We are working on a repository based system. We have stored function names in a database table.
    These functions are nothing but class files.
    Depending upon user selection, function name will be retrieved from the table. We need to execute this function (service),
    but we are getting just a String which contains the function name. In C++ we can make use of Function pointers for the same.
    Is there any means to do it in Java?


  2. #2
    Guest

    Re: Alternative to Function Pointers in Java

    I'll respond, even if it's not C++.

    I'm not 100% conversant in Java, but I know it has a magic trick that C++ does
    not have: it's called "reflection". You can create an instance of any class
    given a string name. For example if you want to create an instance of the
    class foo, you can create it if you have a string equal to "foo". Once the
    instance is created, you can call any member. I'm not sure of the syntax, but
    this is one thing that you cannot do in standard C++.

    Overall, It's *easier* in Java than in C++ to do what you want.

    Check out this link:
    http://www.javasoft.com/docs/books/t...ect/index.html


    Regards,

    Paul McKenzie



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