[DGD] Re: #Including code.

Erwin Harte harte at is-here.com
Sat Jan 10 17:48:15 CET 2004


On Sat, Jan 10, 2004 at 01:17:39PM +0100, Troels Therkelsen wrote:
[...]
> This is all fine and well, but it can have an unexpected
> (indeed even undesirable) effect.  Take this example
> (assume that print() is just a function that outputs to
> the console screen):
> 
> a.c:
> ----
>   void test_proto();
> 
>   void test_proto() {
>     print("*** A ***");
>   }
> 
>   void do_stuff1() {
>     test_proto();
>   }
> 
> b.c:
> ----
>   inherit "a"
> 
>   void test_proto() {
>     print("*** B ***");
>   }
> 
>   void do_stuff2() {
>     test_proto();
>   }
> 
> b->do_stuff1() ==> "*** B ***"
> b->do_stuff2() ==> "*** B ***"

As far as I can see this is a feature, not a bug.  If you wanted
do_stuff1() to insist on using a.c's test_proto(), then make it use a
different function and make it a private or nomask function so nobody
inheriting it can redefine it.  All you did now was provide a default
implementation for test_proto() which you override in b.c.

Did I miss something?

Erwin.
-- 
Erwin Harte <harte at is-here.com>
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list