OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.mike/] [p658.C] - Blame information for rev 823

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do run  }
2
// prms-id: 658
3
 
4
#include 
5
#include 
6
 
7
/* We may not find the libg++ .  */
8
#ifndef FALSE
9
#define FALSE false
10
#endif
11
#ifndef TRUE
12
#define TRUE true
13
#endif
14
 
15
class Object {
16
public:
17
    Object();
18
    Object(const Object&);
19
    ~Object();
20
 
21
    void OK() const;
22
private:
23
    bool _destructed;
24
};
25
 
26
class Char: public Object {
27
public:
28
    Char();
29
    Char(char);
30
    Char(const Char&);
31
    ~Char();
32
 
33
    operator char () const;
34
private:
35
    char _c;
36
};
37
 
38
int main()
39
{
40
    Char r, s;
41
 
42
    r = Char('r');
43
    s = Char('s');
44
}
45
 
46
//
47
// Object stuff
48
//
49
Object::Object():
50
_destructed(FALSE)
51
{}
52
 
53
Object::Object(const Object& other):
54
_destructed(FALSE)
55
{
56
    other.OK();
57
}
58
 
59
Object::~Object()
60
{
61
    OK();
62
    _destructed = TRUE;
63
}
64
 
65
void
66
Object::OK() const
67
{
68
    if (_destructed) {
69
        std::cerr << "FAILURE - reference was made to a destructed object\n";
70
        std::abort();
71
    }
72
}
73
 
74
//
75
// Char stuff
76
//
77
 
78
Char::Char():
79
Object(),
80
_c('a')
81
{ }
82
 
83
Char::Char(char c):
84
Object(),
85
_c(c)
86
{ }
87
 
88
Char::Char(const Char& other):
89
Object(other),
90
_c(other._c)
91
{ }
92
 
93
Char::~Char()
94
{
95
    OK();
96
}
97
 
98
Char::operator char () const
99
{
100
    return _c;
101
}
102
 
103
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.