i want to cast from upper class pointer to lower class i.e from the base class pointer to derived class pointer.
Should i use “Dynamic_cast” or “reinterpret_cast”? please advice me
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.
Don’t use
reinterpret_cast– either usestatic_castordynamic_cast. If you’re sure that the pointer is to exactly that derived class object usestatic_cast, otherwise usedynamic_cast(that will require the base class to be polymorhic) and check the result to ensure that the pointer is indeed to the class you want.