Exceptions -Can I use catch definition multiple times?
I am using a catch statement multiple times. Is there a format so I don't have to use define the catch statement multiple times?
Here is my layout...
Code:
header.h
class someClass {
...
class theThrow{};
...
}
//end of file
definitions.cpp
...
someClass::someFunction(int a){
if(a > o) {
throw theThrow{
}
}
...
//end of file
program.cpp
...
try
{
int a = 1;
someFunction(a);
}
catch
{
//all the catch code or function
}
...
try
{
int b = 2;
someFunction(b);
{
catch
{
//now I have to type all the catch code or function over again
}
...
Is there anyway to define the catch and then just have it automatically pull the catch?
I know I can just put a function in the catch which will save some time but is that the best style?