HI this is shahjahan i need a help in performing some problems in c ++ as i am btech 2nd year student
here is my question:
what header file or what type of file should be included to run the exception handling so as to enable try,throw,catch blocks ??,thankyo..
Exception handling in c++try and catch in c++
Page 1 of 1
6 Replies - 799 Views - Last Post: 18 August 2010 - 09:27 AM
Replies To: Exception handling in c++
#2
Re: Exception handling in c++
Posted 18 August 2010 - 07:56 AM
You dont need a header for exception handling? You can include <exception> that includes a base class specifically designed to declare objects to be thrown as exceptions
#3
Re: Exception handling in c++
Posted 18 August 2010 - 07:58 AM
shahjahan, on 18 August 2010 - 03:47 PM, said:
HI this is shahjahan i need a help in performing some problems in c ++ as i am btech 2nd year student
here is my question:
what header file or what type of file should be included to run the exception handling so as to enable try,throw,catch blocks ??,thankyo..
here is my question:
what header file or what type of file should be included to run the exception handling so as to enable try,throw,catch blocks ??,thankyo..
Just the standard iostream.
I edited your topic title, because it was not very descriptive to your question.
Next time use more descriptive topic titles.
#4 Guest_Six222*
Re: Exception handling in c++
Posted 18 August 2010 - 07:58 AM
None, try, catch and throw are keywords in C++
example:
example:
...
try
{
throw 20;
}
catch (int x)
{
cout << "An exception occurred. Exception Number: " << x << endl;
}
...
#5
Re: Exception handling in c++
Posted 18 August 2010 - 08:01 AM
I'm guessing the OP is using some 20+-year-old compiler and can't understand why exception handling isn't working. Just a guess though.
#6
Re: Exception handling in c++
Posted 18 August 2010 - 08:50 AM
if you want to catch an exception as a string, then you need to include the exception header
eg
eg
#include <exception>
try
{
if (there was a problem)
throw std::exception("Some error");
}
catch (std::exception e)
{
output e.what();
}
#7
Re: Exception handling in c++
Posted 18 August 2010 - 09:27 AM
You don't need any header files but to throw/catch exceptions that are compatible with the standard libraries you can include these:
#include <exception> #include <stdexcept>
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|