<typeinfo>
header has std::type_info::name.
Returns a null-terminated character sequence that may identify the type.
// type_info::name example
#include <iostream> // std::cout
#include <typeinfo> // operator typeid
int main() {
int i;
int * pi;
std::cout << "int is: " << typeid(int).name() << '\n';
std::cout << " i is: " << typeid(i).name() << '\n';
std::cout << " pi is: " << typeid(pi).name() << '\n';
std::cout << "*pi is: " << typeid(*pi).name() << '\n';
return 0;
}
Output:
int is: int
i is: int
pi is: int *
*pi is: int
© 2024 OneMinuteCode. All rights reserved.