Home > Article > Backend Development > Chapter 5 C++: Introduction to statements
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 more catch 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 problems
runtime_error //Problems that can only be detected at runtime <br>
overflow_error // <br>
Underflow_error <br>
Logic_error <br>
domain_error <br>
invalid_arguement <br>
length_error <br>
out_og_range <br><br> <br>- new: bad_alloc
- type_info: bad_cast
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!