Convert std :: string to an existing function with parameters in C ++

I have an implemented function MyFunc(int, double, string)in my project. How can I call this function with the necessary parameters that have a string representation, for example

std::string str = "MyFunc(2, 3.12, \"Lemon Juice\")";

What about standard features, for example, what can I call time()with std::string "time()"?


Well, here is a more detailed task. I have map <string, Data> Data- this is a class wrapper with many children. When I call the method Data.GetValue(), it returns std::string, depending on the internal data of the child class. One of the children Datashould return a string representation int, the other a string representation double, and the last a string representation of the current date and time. Here's the problem - I don’t know how to call a standard function ctime()to get information from one of the children Data.

+5
source share
3 answers

++, . , , ++ ++ , , , .

. :

, :

  • - , , . .
  • .

, :

  • , ++. . , , , ++.

, , :

  • int
  • a double
  • .

, , , , , : (a) , , , (b) - . , , GetValue() . , , , 1970 , GetSecondsSinceEpoc - .

+3

, ++ . .

ROOT ( CERN) ++ . / , ++, .

+1

You cannot do this with C ++.

0
source

All Articles