1.

Which exception is thrown if the typecasting is not done properly?(a) bad_type_cast(b) bad_any_cast(c) type_mismatched(d) bad_cast_mismatchedThis question was posed to me in unit test.My enquiry is from STL Container Any topic in section Class Hierarchies, Library & Containers of C++

Answer»

Correct choice is (b) bad_any_cast

Best explanation: bad_any_cast exception is thrown when TYPECASTING is not done properly by the USER i.e. if any is storing INT value and we are TRYING to cast it into a string then the program will throw bad_any_cast exception.



Discussion

No Comment Found

Related InterviewSolutions