summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-21 00:38:40 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-21 00:38:40 +0000
commit7217d37d1c54b2fe0ea37f5458f62d62cb7ff170 (patch)
treeb4616c52c0a4397e95f931f0d67caa4c2361a347 /etc
parent343c1c8379dea4f166a4d53b0b2cd2ef0dafd098 (diff)
downloadATCD-7217d37d1c54b2fe0ea37f5458f62d62cb7ff170.tar.gz
*** empty log message ***
Diffstat (limited to 'etc')
-rw-r--r--etc/ACE-guidelines.html122
1 files changed, 122 insertions, 0 deletions
diff --git a/etc/ACE-guidelines.html b/etc/ACE-guidelines.html
index 33f008b550e..c98d0952d7c 100644
--- a/etc/ACE-guidelines.html
+++ b/etc/ACE-guidelines.html
@@ -412,6 +412,128 @@ to Graham for providing the OSE tools!<p>
</ul><p>
+ <li><strong>Exceptions</strong><p>
+
+ <ul>
+ <li>There are many ways of throwing and catching exceptions. The
+ code below gives several examples. Note that each method has
+ different semantics and costs. Whenever possible, use the
+ first approach.<p>
+
+ <pre>
+ #include "iostream.h"
+
+ class exe_foo
+ {
+ public:
+ exe_foo (int data) : data_ (data)
+ { cerr << "constructor of exception called" << endl; }
+ ~exe_foo ()
+ { cerr << "destructor of exception called" << endl; }
+ exe_foo (const exe_foo& foo) : data_ (foo.data_)
+ { cerr << "copy constructor of exception called" << endl; }
+ int data_;
+ };
+
+
+ void
+ good (int a)
+ {
+ throw exe_foo (a);
+ };
+
+ void
+ bad (int a)
+ {
+ exe_foo foo (a);
+ throw foo;
+ };
+
+ int main ()
+ {
+ cout << endl << "First exception" << endl << endl;
+ try
+ {
+ good (0);
+ }
+ catch (exe_foo &foo)
+ {
+ cerr << "execption caught: " << foo.data_ << endl;
+ }
+
+ cout << endl << "Second exception" << endl << endl;
+ try
+ {
+ good (0);
+ }
+ catch (exe_foo foo)
+ {
+ cerr << "execption caught: " << foo.data_ << endl;
+ }
+
+ cout << endl << "Third exception" << endl << endl;
+ try
+ {
+ bad (1);
+ }
+ catch (exe_foo &foo)
+ {
+ cerr << "execption caught: " << foo.data_ << endl;
+ }
+
+ cout << endl << "Forth exception" << endl << endl;
+ try
+ {
+ bad (1);
+ }
+ catch (exe_foo foo)
+ {
+ cerr << "execption caught: " << foo.data_ << endl;
+ }
+
+ return 0;
+ }
+ </pre>
+
+ Output is: <p>
+
+ <pre>
+ First exception
+
+ constructor of exception called
+ execption caught: 0
+ destructor of exception called
+
+ Second exception
+
+ constructor of exception called
+ copy constructor of exception called
+ execption caught: 0
+ destructor of exception called
+ destructor of exception called
+
+ Third exception
+
+ constructor of exception called
+ copy constructor of exception called
+ destructor of exception called
+ execption caught: 1
+ destructor of exception called
+
+ Forth exception
+
+ constructor of exception called
+ copy constructor of exception called
+ destructor of exception called
+ copy constructor of exception called
+ execption caught: 1
+ destructor of exception called
+ destructor of exception called
+
+ </pre>
+
+ </ul><p>
+
</ul>