const char* name() const; |
Returns an implementation defined null-terminated character string containing the name of the type. No guarantees are given, in particular, the returned string can be identical for several types and change between invocations of the same program.
Parameters
(none).
Return value
null-terminated character string containing the name of the type.
Notes
With compilers such as gcc and clang, the returned string can be piped through c++filt -t
to be converted to human-readable form.
Example
#include <iostream> #include <typeinfo> struct Base { virtual ~Base() = default; }; struct Derived : Base {}; int main() { Base b1; Derived d1; const Base *pb = &b1; std::cout << typeid(*pb).name() << '\n'; pb = &d1; std::cout << typeid(*pb).name() << '\n'; }
Possible output:
4Base 7Derived
See also
(C++11) | returns a value which is identical for the same types (public member function) |
Please login to continue.