[1117] in java-interest

home help back first fref pref prev next nref lref last post

Re: Assertions in Java (& more)

daemon@ATHENA.MIT.EDU (jim frost)
Sat Aug 19 02:05:37 1995

To: John Barton <jjb@watson.ibm.com>
Cc: "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 15:24:39 EDT."
             <9508181924.AA116973@jjb.watson.ibm.com> 
Date: Fri, 18 Aug 1995 16:13:51 -0400
From: jim frost <jimf@world.std.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++.

I'm glad to hear that some compilers are sane about this kind of
thing.  FWIW, I'm using both SGI's C++ compiler (the one that shipped
with IRIX 5.3, ie less than six months old) and MSVC++ 2.0 (roughly
two years old).

Regardless, those examples illustrate a couple of the surprises people
really see with C++.

jim frost
jimf@world.std.com
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post