home *** CD-ROM | disk | FTP | other *** search
- //----- Anfang BUG3.CPP ------------------------------------
- // (c) 1990 by Thole Groeneveld & toolbox
-
- // Compilerfehler unabhängig von class ostream
- // Beweis durch Ersatz von ostream durch
- // dummy Klasse ausgabe
-
- class ausgabe {
- public:
- ausgabe& operator << (int); // für x und y der
- // Klassen A und B
- };
-
- ausgabe& ausgabe::operator << (int i) {
- i++; // nur um Warnung auszuschalten
- return *this;
- }
-
- class A { // entspricht class smanip_int aus iomanip.h
- public:
- friend ausgabe& operator << (ausgabe&, const A&);
- private:
- int x;
- };
-
- // Fehler tritt nur auf bei Keyword inline oder natürlich
- // bei Definition von << in der Klassendeklaration
- // C++ - Compileroption :
- //
- // [ ] Out-of-line Inline Function
-
- inline ausgabe& operator << (ausgabe& os, const A& a) {
- os << a.x;
- return os;
- }
-
- A dummy() { // entspricht setw(int) aus iomanip.h
- A a;
- return a;
- }
-
- class B { // entspricht class Time aus timeclss.h
- public:
- friend ausgabe& operator << (ausgabe&, const B&);
- private:
- int y;
- };
-
- ausgabe& operator << (ausgabe& os, const B& b) {
- os << dummy() << b.y;
- // Fehlermeldung :
- // B::y is not accessible in function operator << ...
- return os;
- // Warnung :
- // Parameter 'b' is never used in function ...
- }
- //----- Ende BUG3.CPP --------------------------------------