[1101] in java-interest
Re: Assertions in Java (& more)
daemon@ATHENA.MIT.EDU (John Barton)
Fri Aug 18 18:46:56 1995
To: jim frost <jimf@world.std.com>
Cc: John Barton <jjb@watson.ibm.com>,
"John D. Mitchell" <johnm@CSUA.Berkeley.EDU>, anders@in.otc.com.au,
java-interest@java.sun.com
In-Reply-To: Your message of Fri, 18 Aug 1995 11:23:35 EDT.
<199508181523.AA04709@world.std.com>
Date: Fri, 18 Aug 1995 15:24:39 -0400
From: John Barton <jjb@watson.ibm.com>
jim frost writes:
[comments on base-class name hiding in C++, then:]
>A related, but far more serious and subtle, problem is accidentally
>overloading a virtual member function rather than overriding it:
>
> class Foo {
> public:
> virtual void Add(unsigned int);
> };
>
> class Bar : public Foo {
> public:
> void Add(int);
> };
>
>The omission of "unsigned" hides Foo::Add(unsigned int). At best you
>*might* get a signed/unsigned mismatch conflict from the compiler when
>Bar::Add() is called -- but probably not. What I have gotten in cases
>like this is some very hard-to-find bugs.
My C++ compiler says:
"Bar::Add(int)" hides the virtual function "Foo::Add(unsigned int)".
so perhaps you are using an old compiler, one developed before Java
even existed. Compare Java to C++ using today's technology. Java still
has plenty of interesting potential without any need to spread false
rumors about C++.
Just so we can get back to Java, here's a question. How does Java
handle the case above? Which function gets called for
Bar b;
b.Add(5);
Foo& f = b;
f.Add(5);
?
John.
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com