I’m trying to use class as a key of standard map structure.
The usage is like below.
std::map<ClassName, int> someMap;
someMap[ StudentClass ]
someMap[ TeacherClass ]
I’ll use this making Template Factory class.
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.
Do you need the class names to be human reaqdable? If not, then you can use
typeidandtype_info. You can get the string withtype_info::name()(details), but note that it is not guaranteed to be anything readable or even unique, for that matter (thetype_infoobject itself, however, is going to be unique). Beyond that, you’ll have to either rely on non-portable mechanisms or write your own code for doing this.