C Exception Handling

来源:互联网 发布:电脑机器码修改软件 编辑:程序博客网 时间:2024/05/17 20:24

1. The reason why exception handling statements such as: try ... except ... exists is that a programmer may do manually handling of all compilation error by coding corresponding handler function, he or she may not be able to enumerate all run-time exceptions. Therefore, exception handling techniques such as try: except must come into play together with manually exception handling to cover all situations. (ensure the program won't crash)


Try: Except style exception handling will label all the exceptions occurred inside the try-except block enclosed as a designated exception (this exception may not be correct).


2. Zero division error is not considered an exception by C++11, therefore this error must be handled explicitly by the coder 

The exceptions listed in the ISO standard are:


namespace std {
    class logic_error;
        class domain_error;
        class invalid_argument;
        class length_error;
        class out_of_range;
    class runtime_error;
        class range_error;
        class overflow_error;
        class underflow_error;
}


3. For a static language, it is good to take exception handling as a measure to take care of only run-time exceptions.

0 0
原创粉丝点击