Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <typeinfo>
  3. using namespace std;
  4.  
  5.  
  6. /*template <class T>
  7. void printEx(T x)
  8. {
  9. cout<< typeid(x).name() ;///+ " exception: " +x<<endl;
  10. }
  11. */
  12.  
  13.  
  14.  
  15.  
  16. int main()
  17. {
  18.  
  19.  
  20.  
  21. try
  22. {
  23. //char* s="GGEZ";
  24. //int s=10;
  25. //float s=1.999;
  26. char s='#';
  27. throw s;
  28. }
  29. //12.1
  30. catch(int e)
  31. {
  32. cout<<"int exception:"<<e<<endl;
  33. }
  34. catch(double e)
  35. {
  36. cout<<"double exception:"<<e<<endl;
  37. }
  38. catch(char e)
  39. {
  40. cout<<"Char exception:"<<e<<endl;
  41. }
  42. catch(char* e)
  43. {
  44. cout<<"Char* exception:"<<e<<endl;
  45. }
  46. //12.2
  47. catch(...)
  48. {
  49. cout<<"Other exception"<<endl;
  50. }
  51.  
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement