If i cast an object to the base type and store it in a std::map, and then get it back and recast it to the derived type, do i still have the correct data in the derived class members ?
Do i need to make a specific kind of cast ?
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.
If you’re casting pointers to the object, it’s no problem because the pointers will still point to the same object.
If you’re casting the actual object, all information from the subclass will be lost when its converted to the superclass, so casting it back won’t restore that information.