CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

exctest2.cc
Go to the documentation of this file.
1 // Test program to check out environment's exception-handling
2 
3 #include <iostream>
4 using std::cerr;
5 using std::endl;
6 
7 
8 class Exception {
9 public:
10  Exception( const char [] ) {}
11 };
12 
13 
14 class Oops : public Exception {
15 public:
16  Oops( const char s[] ) : Exception( s ) {}
17 };
18 
19 
20 int main() {
21 
22  try {
23  cerr << "Starting main() ..." << endl;
24 
25  cerr << "About to: throw( Oops(\"Ouch\") )" << endl;
26  const Exception & o = Oops("Ouch");
27  throw o;
28  cerr << "The following ought to produce a compilation warning \n"
29  << "Got past: throw( Oops(\"Ouch\") ) -- not good!" << endl;
30  }
31  catch ( const Oops & egad ) {
32  cerr << "Caught: Oops" << endl;
33  }
34  catch ( const Exception & egad ) {
35  cerr << "Caught: Exception" << endl;
36  }
37  catch ( ... ) {
38  cerr << "Caught: don't know what" << endl;
39  }
40 
41  cerr << "Done." << endl;
42  return 0;
43 
44 } // main()
Oops::Oops
Oops(const char s[])
Definition: exctest2.cc:16
Oops
Definition: exctest2.cc:14
main
int main()
Definition: exctest2.cc:20
Exception::Exception
Exception(const char[])
Definition: exctest2.cc:10
Exception
Definition: exctest2.cc:8
s
Methods applicble to containers of as in std::list< LorentzVector > s
Definition: keyMergeIssues.doc:328