GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » Tracking » Smoothing method in class Kalman
Re: inheritance in C++ important question [message #8084 is a reply to message #8083] Mon, 16 March 2009 14:48 Go to previous messageGo to previous message
Anonymous Poster From: 141.39.167*
Hi Stefano,

thanks for your interest. My main interst lies in the second doit call (not so much the third, which I think is obvious). But the second call does something confusing. Since in C the doit method is not virtual, in fact the call to y->doit() (y is a C*) calls the code in C, and not the iherited D class. This is clear to me, since there is no vtable for that method.

But: This is dangerous. When I write a method in the super class I would like to prohibit people to reimplement this method, because they mistakenly will assume that their code will be called. However if the object is accessed through a super class pointer, like in my example C* y = new D; the code you implement in D will never be called through the super class pointers.

Any clearer? Please keep asking what I didnt make clear. This one is really important for all object oriente code. I naively assumed that the compiler would prohibit you from doing that!

Cheers, Christian
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Genfit Doxygen Documentation
Next Topic: problem with TrackCand
Goto Forum:
  


Current Time: Sat Apr 27 21:12:26 CEST 2024

Total time taken to generate the page: 0.00981 seconds