c++ - The parameter for the 'catch' -
this question has answer here:
- catch exception pointer in c++ 5 answers
i read "programming: principles , practice using c++" book (bjarne stroustrup). author writes:
catch (runtime_error e) but writes:
catch (runtime_error& e) as know, first variant creates copy of source, second uses link. or mistaken? not important "catch" in case?
i have expected of time, use:
catch ( runtime_error const& e ) the difference between catch value , catch reference same pass value , pass reference function parameter. important difference when catching reference, dynamic type can derived type, value result in slicing (because of copy).
also, if catch non-const reference, , modify exception object, rethrow, modified object propagate.
Comments
Post a Comment