home *** CD-ROM | disk | FTP | other *** search
- //----- Anfang BUG2.CPP ------------------------------------
- // (c) 1990 by Thole Groeneveld & toolbox
- //
-
- #include <iostream.h>
-
- class A { // entspricht class smanip_int aus iomanip.h
- public:
- friend ostream& operator << (ostream&, 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 ostream& operator << (ostream& os, const A& a) {
- os << a;
- return os;
- }
-
- A dummy() {// entspricht setw(int) aus iomanip.h
- A a;
- return a;
- }
-
- class B { // entspricht class Time aus timeclss.h
- public:
- friend ostream& operator << (ostream&, const B&);
- private:
- int y;
- };
-
- ostream& operator << (ostream& 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 BUG2.CPP --------------------------------------