Chapter 3 C ++ Exception Handling Mechanism and rtti
I. c ++ Exception Handling
So far, I have no experience in using the "exception mechanism" in actual projects, so I have no idea about this part. In the qt4 framework, exceptions are not recommended.
Interestingly, Google's programming specifications also suggest: "We don't use C ++ exceptions .".
Of course, it cannot be questioned that the exception handling technology of C ++ can enhance the robustness of software. For usage of exceptions, please wait for further research.
Ii. rtti (runtime type recognition)
1. In order to get the object type information at runtimeType_info, C ++ adds two operators:Typeid ()AndDynamic_cast <>.
2. type_info has three member functions: Operator = () and operator! = () And name ().
3. The typeid () operator does not need to traverse the inheritance tree. In fact, the overhead of calling the typeid () operator is equal to the overhead of dynamic binding of the virtual function.