Chapter 5 Statement
- C specifies that else matches the nearest if that hasn't been matched yet, thus removing the ambiguity.
switch (ch) { case 'a': case 'b': ++n; break; }
integer constant expression.
do statementwhile (condition); //注意分号
(throw expression): The anomaly detection part uses throw expressions to indicate that it has encountered a problem that cannot be handled.
(try block):try starts with one or morecatch clauses(catch clause) Finish.
.
try { //program-statements } catch (/*exception-declaration异常声明*/) { //handler-statements } catch (/*exception-declaration*/) { //handler-statements } //...
Specify the Exception types that the catch clause can handle.
- exception: defines the most common exception class exception, which only reports the occurrence of exceptions and does not provide any additional information.
- stdexcept
- Use string objects or C-style string initialization
- There is only one member function what()
Exception //The most common problemsruntime_error //Problems that can only be detected at runtime
- type_info: bad_cast
overflow_error //
Underflow_error
Logic_error
domain_error
invalid_arguement
length_error
out_og_range
- new: bad_alloc
Reference: C Primer 5th Edition
Related articles:
Chapter 4 C: Expression Concept - Application of OperatorsChapter 6 C: Function Basics and ApplicationThe above is the detailed content of Chapter 5 C++: Introduction to statements. For more information, please follow other related articles on the PHP Chinese website!