Calling function based on passing variable.......

This is a discussion on Calling function based on passing variable....... within the C++ Programming forums, part of the General Programming Boards category; can we calling defined function based on passing variable in C++ like on PHP? for example, in PHP we can ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    7

    Calling function based on passing variable.......

    can we calling defined function based on passing variable in C++ like on PHP?

    for example, in PHP we can calling function like:

    Load_$Input();


    CMIIW.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,304
    No, C++ does not support variable functions. However, as long as you can map strings to function pointers (or function objects), you can do something similiar.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    7
    is there any tutorial about that? sorry i'm newbie in C++.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,304
    Tutorial on std::map and std::unordered_map, or tutorial on function pointers and function objects?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-26-2011, 05:44 AM
  2. Calling a function named in a variable.
    By JohnAnon in forum C++ Programming
    Replies: 25
    Last Post: 04-01-2011, 01:38 AM
  3. Replies: 6
    Last Post: 06-01-2007, 08:02 PM
  4. Replies: 5
    Last Post: 01-13-2006, 12:00 AM
  5. Passing a function name as a variable to execute it?
    By Zuul in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2002, 12:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21