Skip to content

Instantly share code, notes, and snippets.

@sinannar
Created January 18, 2012 16:56
Show Gist options
  • Save sinannar/1634027 to your computer and use it in GitHub Desktop.
Save sinannar/1634027 to your computer and use it in GitHub Desktop.
catch(...) block learning
#include <iostream>
using namespace std;
class Exception
{
public:
Exception(string e)
{
situation=e;
}
string getProblem() const
{
return situation;
}
private:
string situation;
};
void funA();
void funB();
void funC();
void funD();
int main()
{
try{
cout<<"calling A"<<endl;
funA();
cout<<"back from A"<<endl;
}
catch(...){///look here carefully
}
cout<<"catched it"<<endl;
return 0;
}
void funA()
{
cout<<"calling B"<<endl;
funB();
cout<<"back from B"<<endl;
}
void funB()
{
cout<<"calling C"<<endl;
funC();
cout<<"back from C"<<endl;
}
void funC()
{
cout<<"calling D"<<endl;
funD();
cout<<"back from D"<<endl;
}
void funD()
{
if(true)
throw Exception("excp from D");
cout<<"Here i am on D"<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment