Q:

Can I get input without declaring a variable type or declare multiple type for same variable in c++?

I want to get a input that can be integer or string and want to pass it to overloaded function, so that candidate function can be automatically detected and output generated. Is there a way to do that?

A:

There's no way to do it automatically, but you can certainly do it programmatically.

Read in a string.
Check if the string is a valid number.
If it is a number, get its value (via atoi() or similar) and pass it to the integer version of your function.
Otherwise, pass the string to the string version of your function.

There is no way to get this "for free" since the compiler can't know at compile time whether the input is going to be a number or not.

