1.

How Can I Be Thrown Polymorphically?

Answer»

The following code can be used to throw i polymorphically:

classExceptionParent { ); CLASSE,cceptionChild : public ExceptionParent ( ); void f(ExceptionParent8 e) /1 throw e; void go ExceptionChild e; TRY( fCc); catch (ExceptionChild& e) ( //...code to handle ExceptlonChild... catch C...) ( //...code to handle other exceptions... ) )

In the PRECEDING code, you can enter the catch (...) clause in the absence of throwing i polymorphically. The throw e in the function f () throws the same type of an object as an expression of STATIC type.

The following code can be used to throw i polymorphically:

In the preceding code, you can enter the catch (...) clause in the absence of throwing i polymorphically. The throw e in the function f () throws the same type of an object as an expression of static type.



Discussion

No Comment Found