Message-ID: <354C6526.866A90FB@uol.com.br> Date: Sun, 03 May 1998 09:37:58 -0300 From: "Juciê Dias Andrade" MIME-Version: 1.0 To: Nathan Cournia , djgpp AT delorie DOT com Subject: Re: Inheritance Problem References: <354A206B DOT 586A3F60 AT frank DOT mtsu DOT edu> <354B2DE4 DOT 9981F3C9 AT uol DOT com DOT br> <354BB946 DOT F6E8A824 AT frank DOT mtsu DOT edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk >In my bstClass I have the public search function declared as >virtual. It doesn't matter. The behavior that is to be overriden is method SearchTree() and not Search(). Search() does always the same, ok? >I want to override the protected recursive function that it >calls. Yes, you know what you want. virtual stands for "this method can have a different bahavior in a derived class" and no "this method can call another method that can have a different bahavior in a derived class". >Do I declare the protected function as virtual and is that >allowed? Yes, it is. Overriding has nothing to do with access control (public, protected, private). SearchTree() could be private! Nathan, I will tell you the whole history. If you take a look at the generated assembly code you will se the difference is at the method call. The compiler sees a method call and thinks "Is the called method virtual?". If it is the case the compiler generates a indirect call, a smart one. This call, at execution time, gets the address of the proper method from a table that is connected with the real class of the called object. This issue is actually confusing sometimes. I hope this explanation improves your understanding of what is "virtual". []s