home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12647 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.4 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: kring@efes.physik.uni-kl.de (Jochen Voss)
  4. Subject: Overloading Parent Declaration: Bug or Feature?
  5. Message-ID: <1992Aug20.141830.3079@rhrk.uni-kl.de>
  6. Sender: kring@efes.physik.uni-kl.de (Thomas Kettenring)
  7. Organization: FB Physik, Universitaet Kaiserslautern, Germany
  8. Date: Thu, 20 Aug 1992 14:18:30 GMT
  9. Lines: 38
  10.  
  11. I tried to compile the following program with GNU C++ version 2.1
  12. (Atari ST, Patchlevel 2):
  13.  
  14.     #include <stream.h>
  15.  
  16.     class B {
  17.     public:
  18.         void f(int x)    { cout << "B::f(" << x << ")\n"; }
  19.     };
  20.  
  21.     class D : public B {
  22.     public:
  23.         void f(char *str)    { cout << "D::f(" << str << ")\n"; }
  24.     };
  25.  
  26.     main()
  27.     {
  28.         D d;
  29.  
  30.         d.f(1);        // (*) should be an error ?
  31.         d.f("hallo");
  32.     }
  33.  
  34. It compiles without warnings (even with the -Wall flag set) and outputs
  35.     B::f(1)
  36.     D::f(hallo)
  37. when run.  But in Bjarne Stroustrup's Book `Die C++ Programmiersprache'
  38. (2. Auflage, 1992) in section R.13.1 he writes that the statement at the (*)
  39. is an error because D::f(char*) hides B::f(int). B::f(int) is not overloaded
  40. with D::f(char*) because the functions have different scopes.
  41.  
  42. Is this a bug or a feature? Shouldn't I at least get a warning?
  43.  
  44. --
  45. VinK - Voss is not Kring
  46.  
  47. You can e-mail me at `kring@physik.uni-kl.de'.
  48. (use `c/o Jochen' in the Subject)
  49.