2
Good afternoon, Is there a function in C++ that checks whether the variable is a string or numeric?
An example is: In PHP use is_string(variable) or is_numeric(variable).
2
Good afternoon, Is there a function in C++ that checks whether the variable is a string or numeric?
An example is: In PHP use is_string(variable) or is_numeric(variable).
2
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 type ID. So:
#include <typeinfo>
// …
std::cout << typeid(a).name() << '\n';
Has that question here in Stackoverflow which explains the difference between the 2.
Browser other questions tagged c++
You are not signed in. Login or sign up in order to post.
I don’t know if there is a native function. But there are implementations like this one: http://stackoverflow.com/a/4654718/3293600
– Pedro Laini
You want to check whether the type of the variable itself, within, for example, a template function, or you have a string and want to validate whether its content is number?
– C. E. Gesser