Thread: random access function table design?

  1. #1
    Registered User
    Join Date
    Oct 2002

    random access function table design?

    I just got back to work after my semester of software engineering, and I think I learned a lot of good stuff. The only problem is that everything I learned is in python, and some things I'm not quite sure how to apply in C++.

    I need to make a function table of some kind for a controller class that I'm working on. I would like it to work like the function table in my python program (although I don't know if it's possible, at least in an easy to program manner) where the controller instance returns a function object of the type specified in the argument passed to it.

    After the function is returned by the controller, the parameters may be passed to it, like in the python code below:

    controller.get_function(foo)(arg1, arg2, ...)
    If there is some way to provide similar functionality using C++ (which I'm sure there is, I just hope it's not an enormously difficult problem to do) I'd like to continue extend this style of programming to my C++ work.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    It's just a matter of syntax. Start here:


  3. #3
    Registered User
    Join Date
    Mar 2002
    Why don't you look up function pointers, function objects, and/or functors. An array of function pointers allows you to select a given function at runtime rather than compile time and, to me, sounds similar to what you are tring to do.
    You're only born perfect.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Random Function
    By T1m in forum C Programming
    Replies: 5
    Last Post: 01-06-2009, 08:41 AM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. inputting words from a file
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2003, 07:18 AM