Try Catch


//file : Try Catch.cpp
//Author : Jemmy R. Mongi

#include <iostream>
#include <exception>
using namespace std;

struct MyException : public exception
{
  const char * what () const throw ()
  {
    return "C++ Exception";
  }
};

int main()
{
  try
  {
    throw MyException();
  }
  catch(MyException& e)
  {
    std::cout << "MyException caught" << std::endl;
    std::cout << e.what() << std::endl;
  }
  catch(std::exception& e)
  {
    //Other errors
  }
}

No comments:

Post a Comment

Tutorial Lengkap Hosting Website Gratis Dengan Gambar

Hallo Guys.. sudah sangat lama sekali sejak terakhir kali saya melakukan posting di blogger ini... kalau saya tidak salah terakhir saya ...