source: trunk/testcase/throw.cpp@ 714

Last change on this file since 714 was 575, checked in by bird, 22 years ago

* empty log message *

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 694 bytes
Line 
1#include <stdio.h>
2
3
4class foo
5{
6 int i;
7public:
8 foo(int i) : i(i)
9 {
10 fprintf(stderr, "constructor 1\n");
11 }
12
13 foo() throw(int) : i(1)
14 {
15 fprintf(stderr, "constructor 2\n");
16 throw(1);
17 }
18
19 int get() const
20 {
21 return i;
22 }
23
24};
25
26
27static foo o2(2);
28
29int main()
30{
31 int rc;
32
33 if (o2.get() == 2)
34 fprintf(stderr, "o2 ok\n");
35 else
36 fprintf(stderr, "o2 failed\n");
37
38 try
39 {
40 fprintf(stderr, "creating\n");
41 foo o;
42 fprintf(stderr, "no throw!\n");
43 rc = o.get();
44 }
45 catch (int e)
46 {
47 fprintf(stderr, "caught e=%d\n", e);
48 rc = 0;
49 }
50
51 return rc;
52}
Note: See TracBrowser for help on using the repository browser.