Code:
class BaseExcep
{
protected:
std::string message;
public:
BaseExcep(std::string);
virtual void printException();
};
class DerivedExcep1 : public BaseExcep
{
public:
DerivedExcep1(std::string);
};
class DerivedExcep2 : public DerivedExcep1
{
public:
DerivedExcep2(std::string);
};
int main()
{
try
{
throw DerivedExcep2("Derived2");
}
catch(BaseExcep& ex)
{
/ *
* Here i need to find which exception type is actually thrown
* whether it is DerivedExcep1 or DerivedExcep2 or
* BaseExcep itself.
* i cant use dynamic_cast in this, since it is a reference
* can someone help me out
*/
}
Comment