retagged by
683 views
0 votes
0 votes

#include<iostream> 
using namespace std; 
  
class Base {}; 
class Derived: public Base {}; 
int main() 
{ 
   Derived d; 
   // some other stuff 
   try { 
       // Some monitored code 
       throw d; 
   } 
   catch(Base b) {  
        cout<<"Caught Base Exception"; 
   } 
   catch(Derived d) {  //This catch block is NEVER executed 
        cout<<"Caught Derived Exception"; 
   } 
   getchar(); 
   return 0; 
} 

am throwing derived class object but base class exception is caught can anyone explain how it is happened internally…….

and what is class Derived: public Base {};

 

retagged by

Please log in or register to answer this question.

Related questions

1 votes
1 votes
0 answers
3