Can someone please explain this to me
dynamic_cast<SomeObject *>( &(*similarObject) );
What is the point of doing the address of a dereferenced pointer? Wouldn’t the pointer itself just be the address of it?
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.
It may be that the type of
similarObjecthas overloadedoperator*and so it returns something whose address you’re passing todynamic_cast.&(*x)andxmay not be always the same thing. For example, think of iterator:Then
itand&(*it)are two different thing:itisstd::map<int, int>::iterator&(*it)isstd::pair<int,int>*They’re not at all same. Similar thing may happen with your code-snippet as well.