The segmentation error at execution of code while throwing exception...
This is an actual working code with segmentation error (Core). It dumps core while throwing exception from my_print function. I was wondering this is the best way to do this...
#include <stdio.h>
#include <iostream.h>
#include <stdexcept>
#define PD_BEGIN_DESTRUCTOR \
bool unwinding = std::uncaught_exception(); \
try \
{
#define PD_END_DESTRUCTOR\
}\
catch(...)\
{\
if (!unwinding )\
throw; \
}
class e : public std::exception
{
public:
e(){
cout<<"Exception from class e without error"<<endl;
}
};
class myclass{
public:
myclass(){
cout><<"This class is to test destrcutors"<<endl;
}
~myclass(){
PD_BEGIN_DESTRUCTOR
cout><<"This class is to test destructor - at destructor"<<endl;
PD_END_DESTRUCTOR
}
void my_print(){
cout><<"This print the statement before exception"<<endl;
e exp;
throw exp;
}
};
int main()
{
myclass* my=new myclass;
my->my_print();
return 0;
}

