The Gateway to Computer Science Excellence
0 votes
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"; 
   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 {};


in Programming by (171 points)
retagged by | 67 views

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,324 answers
105,169 users