[ create a new paste ] login | about

Link: http://codepad.org/TRwdnYtV    [ raw code | output | fork ]

hurracane - C++, pasted on Dec 22:
# include <iostream>
using namespace std ;

struct Error {
	virtual int level ( ) { return 1; }
	virtual ~Error() {};
} ;
struct SeriousError : public Error {
	virtual int level ( ) { return 2; }
} ;

void g() { cout << " ga " ; throw SeriousError ( ) ; cout << " gb " ; }

void f() { cout << " fa " ; g ( ) ; cout << " fb " ; }

int main() {
	try {
		cout << "ma";
		try {
			f ( ) ;
			cout << " mb" ;
		} // end of inner try
		catch (Error e) { cout << e.level(); throw; }
	} // end of outer try
	catch (SeriousError& e) { cout << e.level(); }
	cout << endl ;
	return 0;
}


Output:
1
ma fa  ga 12


Create a new paste based on this one


Comments: