Is there C/C++ equivalent of eval(“function(arg1, arg2)”)?

后端 未结 5 436
一个人的身影
一个人的身影 2020-11-30 07:41

it need a way to call function whose name is stored in a string similar to eval. Can you help?

5条回答
  •  情书的邮戳
    2020-11-30 08:12

    There are at least 2 alternatives:

    • The command pattern.
    • On windows, you can use GetProcAddress to get a callback by name, and dlopen + dlsym on *nix.

提交回复
热议问题