
Untitled
By:
GGMethos on
Sep 19th, 2013 | syntax:
C++ | size: 1.44 KB | hits: 13 | expires: Never
#include "Hello.h"
#include <assert.h>
int main(int argc, char** args, char** argsenv) {
Hello h = Hello() ;
Hello* ph = new Hello ();
Hello* phArgument;
cout << argc << std::endl;
for (int i = 0 ; i < argc; i++ )
cout << *(args+i) << std::endl;
try
{
phArgument = new Hello ("One Ring to rule them all");
}
catch (std::invalid_argument ia)
{
cerr << "Invalid argument, Hello not passed to constructor, Passed-" << ia.what() << endl ;
}
try
{
ph -> setcshelloReply ("One Ring to rule them all\n");
}
catch (std::out_of_range l)
{
cerr << "Hello exceeded String Length " << l.what() << endl ;
}
catch(...)
{
cerr << "Error not Caught..." << std::endl;
return 0;
}
cout << ph -> getcshelloReply();
try
{
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");
}
catch (std::out_of_range l)
{
cerr << "Hello exceeded String Length " << l.what() << endl ;
}
catch (Hello::Length l ) {
assert (l.getLength()!=0);
cerr << " String overflow - " << l.getLength() << " needed" << std::endl;
}
catch (std::bad_alloc alloc)
{
}
catch (std::bad_cast cast)
{
}
catch (std::bad_exception be)
{
}
catch (std::overflow_error ofe)
{
}
catch(...)
{
cerr << "Error not Caught..." << std::endl;
}
cout << h.getcshelloReply();
return 0;
}