2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.mike / p658.C
blob1a4fefddc07bd88872918f22f231bdcba33952f2
1 // { dg-do run  }
2 // prms-id: 658
4 #include <iostream>
5 #include <cstdlib>
7 /* We may not find the libg++ <bool.h>.  */
8 #ifndef FALSE
9 #define FALSE false
10 #endif
11 #ifndef TRUE
12 #define TRUE true
13 #endif
15 class Object {
16 public:
17     Object();
18     Object(const Object&);
19     ~Object();
21     void OK() const;
22 private:
23     bool _destructed;
26 class Char: public Object {
27 public:
28     Char();
29     Char(char);
30     Char(const Char&);
31     ~Char();
33     operator char () const;
34 private:
35     char _c;
38 int main()
40     Char r, s;
42     r = Char('r');
43     s = Char('s');
47 // Object stuff
49 Object::Object():
50 _destructed(FALSE)
53 Object::Object(const Object& other):
54 _destructed(FALSE)
56     other.OK();
59 Object::~Object()
61     OK();
62     _destructed = TRUE;
65 void
66 Object::OK() const
68     if (_destructed) {
69         std::cerr << "FAILURE - reference was made to a destructed object\n";
70         std::abort();
71     }
75 // Char stuff
78 Char::Char():
79 Object(),
80 _c('a')
81 { }
83 Char::Char(char c):
84 Object(),
85 _c(c)
86 { }
88 Char::Char(const Char& other):
89 Object(other),
90 _c(other._c)
91 { }
93 Char::~Char()
95     OK();
98 Char::operator char () const
100     return _c;