Good afternoon, Is there a function in C ++ that checks whether the variable is a string or numeric?
An example: In PHP I use is_string (variable) or is_numeric (variable).
Good afternoon, Is there a function in C ++ that checks whether the variable is a string or numeric?
An example: In PHP I use is_string (variable) or is_numeric (variable).
If you are using GCC you can use typeof. It returns a string with the type of the variable. Ex.:
#include <iostream>
std::cout << typeof(int&) << '\n'; // int
You can also use the type ID. So:
#include <typeinfo>
// …
std::cout << typeid(a).name() << '\n';
Have this question here in Stackoverflow in English that explains the difference between the 2 .