0
Typeid with virtual keyword not giving derived class name
Hi When I have pb2 as base* pointing to derived class object, does that not mean typeid on pb2 must be delivered class ? Am I missing something here? Refer code below: https://code.sololearn.com/cyJJPYTn7NcV/?ref=app
2 Antworten
+ 1
typeid of a pointer will always be the declared type, because that's the real type of the pointer itself. in order to know the real type of the object the pointer points to, you need to dereference the pointer to get the actual type :
https://code.sololearn.com/cTJnOcJ6fcc5/?ref=app
https://www.sololearn.com/en/compiler-playground/cTJnOcJ6fcc5
0
Thank you so much..!