May 2012
Intermediate to advanced
679 pages
16h 56m
English
We have studied inheritance. We have seen that a base class pointer can point to derived class objects. Well this principle can be used to our advantage. In some big program we can have our own exception class say BPexception. We can have exception classes defined and organised as inheritance tree. When a situation demands, we should throw appropriate exception object, but created with the help of base class pointer. Then design of catch clause can be simple. It has to basically have a parameter as base class pointer. Only a single catch clause is sufficient. Inside the catch block we can take appropriate action.
Read now
Unlock full access