Click here to Skip to main content
15,895,667 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow Can i Call a Function Providing its name as a string Pin
MIAN KAMRAN6-Sep-06 1:29
MIAN KAMRAN6-Sep-06 1:29 
QuestionRe: How Can i Call a Function Providing its name as a string Pin
Rajesh R Subramanian6-Sep-06 1:36
professionalRajesh R Subramanian6-Sep-06 1:36 
AnswerRe: How Can i Call a Function Providing its name as a string Pin
Cedric Moonen6-Sep-06 1:38
Cedric Moonen6-Sep-06 1:38 
AnswerRe: How Can i Call a Function Providing its name as a string Pin
Frank K6-Sep-06 2:44
Frank K6-Sep-06 2:44 
AnswerRe: How Can i Call a Function Providing its name as a string Pin
Chris Losinger6-Sep-06 2:54
professionalChris Losinger6-Sep-06 2:54 
AnswerRe: How Can i Call a Function Providing its name as a string Pin
Viorel.6-Sep-06 3:12
Viorel.6-Sep-06 3:12 
AnswerRe: How Can i Call a Function Providing its name as a string Pin
yjzh6-Sep-06 4:20
yjzh6-Sep-06 4:20 
AnswerRe: How Can i Call a Function Providing its name as a string Pin
Rilhas8-Sep-06 9:29
Rilhas8-Sep-06 9:29 
Complementing to the other answers already given, the quick answer would be no, at least not in the way BASIC (for example) lets you do it (something like execute("a=myfunc(10,20)").

The process of calling functions based on the contents of a string has to be manually coded in some way. The most "automatic" way is the already mentioned "GetProcAddress" (you can hide most of the steps required inside macros or in a general purpose function), but prototypes will be always a pain (unless if they are, trivially, the same).

Depending on the extent of work you are willing to do, you can go as far as building your own C/C++ interpreter. I did this once, for a home automation system, where I made a program to go through all of my header files, scan function names and prototypes, and write code to execute the correct function with the correct parameters based on the contents of a string (the command entered by the user). Is not very hard work if you control the classes and functions. If not then be prepared for trouble.

I hope this helps,
Rilhas
QuestionWinsock TCP Client disconnect Pin
Eytukan6-Sep-06 1:21
Eytukan6-Sep-06 1:21 
AnswerRe: Winsock TCP Client disconnect Pin
Frank K6-Sep-06 2:29
Frank K6-Sep-06 2:29 
GeneralRe: Winsock TCP Client disconnect Pin
Eytukan6-Sep-06 3:17
Eytukan6-Sep-06 3:17 
AnswerRe: Winsock TCP Client disconnect Pin
cmk6-Sep-06 20:35
cmk6-Sep-06 20:35 
GeneralRe: Winsock TCP Client disconnect Pin
Eytukan7-Sep-06 21:09
Eytukan7-Sep-06 21:09 
QuestionData Type Conversion Problem Pin
Programm3r6-Sep-06 0:47
Programm3r6-Sep-06 0:47 
AnswerRe: Data Type Conversion Problem Pin
Waldermort6-Sep-06 0:58
Waldermort6-Sep-06 0:58 
Questionhow to dermine weather the Given string is numeric or not , vc++ Pin
cybersadhu6-Sep-06 0:34
cybersadhu6-Sep-06 0:34 
AnswerRe: how to dermine weather the Given string is numeric or not , vc++ Pin
toxcct6-Sep-06 0:36
toxcct6-Sep-06 0:36 
AnswerRe: how to dermine weather the Given string is numeric or not , vc++ Pin
Waldermort6-Sep-06 0:39
Waldermort6-Sep-06 0:39 
AnswerRe: how to dermine weather the Given string is numeric or not , vc++ Pin
Hamid_RT6-Sep-06 0:52
Hamid_RT6-Sep-06 0:52 
AnswerRe: how to dermine weather the Given string is numeric or not , vc++ Pin
David Crow6-Sep-06 4:04
David Crow6-Sep-06 4:04 
GeneralRe: how to dermine weather the Given string is numeric or not , vc++ Pin
toxcct6-Sep-06 4:53
toxcct6-Sep-06 4:53 
GeneralRe: how to dermine weather the Given string is numeric or not , vc++ Pin
David Crow6-Sep-06 6:15
David Crow6-Sep-06 6:15 
AnswerRe: how to dermine weather the Given string is numeric or not , vc++ Pin
Dennis Furlaneto6-Sep-06 5:59
Dennis Furlaneto6-Sep-06 5:59 
GeneralRe: how to dermine weather the Given string is numeric or not , vc++ Pin
toxcct6-Sep-06 21:13
toxcct6-Sep-06 21:13 
QuestionNeed help: fatal error C1004: unexpected end of file found Pin
bloodwinner6-Sep-06 0:33
bloodwinner6-Sep-06 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.