When will I use bad_typeid?

When will the bad_typeid exception be used?

+3
source share
2 answers

This type of exception is not commonly used. Instead, it exists only so that you can recognize it. If the tester or user has sent you a crash report that mentions bad_typeidyou, you will know what error to look for when starting debugging.

You really shouldn't throw this exception yourself, and I don't think you even wanted to catch it. In the end, what could you do to eliminate the root cause of this error in your program? The way to recover from this type of exception is to find the error, fix it, recompile and distribute the updated version of your program, which does not try to use the operator typeidfor invalid values.

+2
source

The bad_typeid exception is thrown by the typeid operator when the operand for typeid is a NULL pointer. In other words, class bad_typeid exceptions are thrown when typeid is called using the dereferenced null pointer.

+2
source

Source: https://habr.com/ru/post/1795921/


All Articles