Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)

Untitled

By: GGMethos on Sep 19th, 2013  |  syntax: C++  |  size: 1.44 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "Hello.h"
  2.  
  3. #include <assert.h>
  4.  
  5.  
  6. int main(int argc, char** args, char** argsenv) {
  7.         Hello h = Hello() ;
  8.         Hello* ph = new Hello ();
  9.         Hello* phArgument;
  10.  
  11.         cout << argc << std::endl;
  12.         for (int i = 0 ; i < argc; i++ )
  13.                 cout << *(args+i) << std::endl;
  14.  
  15.         try
  16.         {
  17.                 phArgument = new Hello ("One Ring to rule them all");
  18.         }
  19.         catch (std::invalid_argument ia)
  20.         {
  21.                 cerr << "Invalid argument, Hello not passed to constructor, Passed-" << ia.what() << endl ;
  22.         }
  23.        
  24.  
  25.         try
  26.         {
  27.                 ph -> setcshelloReply ("One Ring to rule them all\n");
  28.         }
  29.         catch (std::out_of_range l)
  30.         {
  31.                 cerr << "Hello exceeded String Length " << l.what() << endl ;
  32.         }
  33.        
  34.         catch(...)
  35.         {
  36.                 cerr << "Error not Caught..." << std::endl;
  37.                 return 0;
  38.         }
  39.        
  40.         cout << ph -> getcshelloReply();
  41.        
  42.         try
  43.         {
  44.                 h.setcshelloReply ("Mordor -  One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them\n");
  45.  
  46.         }      
  47.         catch (std::out_of_range l)
  48.         {
  49.                 cerr << "Hello exceeded String Length " << l.what() << endl ;
  50.         }
  51.         catch (Hello::Length l ) {
  52.                 assert (l.getLength()!=0);
  53.                 cerr << " String overflow - " << l.getLength() << " needed" << std::endl;
  54.         }
  55.         catch (std::bad_alloc alloc)
  56.         {
  57.         }
  58.         catch (std::bad_cast cast)
  59.         {
  60.         }
  61.         catch (std::bad_exception be)
  62.         {
  63.         }
  64.         catch (std::overflow_error ofe)
  65.         {
  66.         }
  67.         catch(...)
  68.         {
  69.                 cerr << "Error not Caught..." << std::endl;
  70.         }
  71.  
  72.  
  73.         cout << h.getcshelloReply();
  74.  
  75.        
  76.         return 0;
  77. }