home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!rz.uni-karlsruhe.de!stepsun.uni-kl.de!sun.rhrk.uni-kl.de!efes.physik.uni-kl.de!kring
- From: kring@efes.physik.uni-kl.de (Jochen Voss)
- Subject: Overloading Parent Declaration: Bug or Feature?
- Message-ID: <1992Aug20.141830.3079@rhrk.uni-kl.de>
- Sender: kring@efes.physik.uni-kl.de (Thomas Kettenring)
- Organization: FB Physik, Universitaet Kaiserslautern, Germany
- Date: Thu, 20 Aug 1992 14:18:30 GMT
- Lines: 38
-
- I tried to compile the following program with GNU C++ version 2.1
- (Atari ST, Patchlevel 2):
-
- #include <stream.h>
-
- class B {
- public:
- void f(int x) { cout << "B::f(" << x << ")\n"; }
- };
-
- class D : public B {
- public:
- void f(char *str) { cout << "D::f(" << str << ")\n"; }
- };
-
- main()
- {
- D d;
-
- d.f(1); // (*) should be an error ?
- d.f("hallo");
- }
-
- It compiles without warnings (even with the -Wall flag set) and outputs
- B::f(1)
- D::f(hallo)
- when run. But in Bjarne Stroustrup's Book `Die C++ Programmiersprache'
- (2. Auflage, 1992) in section R.13.1 he writes that the statement at the (*)
- is an error because D::f(char*) hides B::f(int). B::f(int) is not overloaded
- with D::f(char*) because the functions have different scopes.
-
- Is this a bug or a feature? Shouldn't I at least get a warning?
-
- --
- VinK - Voss is not Kring
-
- You can e-mail me at `kring@physik.uni-kl.de'.
- (use `c/o Jochen' in the Subject)
-