How can I get the type name of a supplied type as string with C++ using Visual Studio 2010?
Example:
class MyClass { ... };
std::string typestr;
typestr = typeof( MyClass );
//typestr should hold "MyClass" now
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Will return type name. This feature is “implementation defined” and standard doesn’t saying what exacly name function must return, however in VC++ it is returning what you need (note, that in g++ name function have different behavior).
For more information see this and this links.