+ 2
How to define the type of variable in the execution, when that type depends of the input (C++)?
I'm doing a program that takes a type of variable as input, such as char, int, string, and so on; and prints the size in bytes of that type of variable with sizeof() function. But I have to declare the type of the input variable before the user enters it. There is any way to define the type in run time?, as it depends of input.
1 Answer
+ 7
I think it goes against the concept of static typing discipline of C++. Although, it would be a great chance to learn, in case it was possible.
I also think that use of dynamic typing language for such plan is in order.