catch-all A
catch
clause in which the exception declaration is(...)
. A catch-all clause catches an exception of any type. It is typically used to catch an exception that is detected locally in order to do local cleanup. The exception is then rethrown to another part of the program to deal with the underlying cause of the problem.
catch clause Part of the program that handles an exception. A
catch
clause consists of the keywordcatch
followed by an exception declaration and a block of statements. The code inside acatch
does whatever is necessary to handle an exception of the type defined in its exception declaration.
constructor order Under nonvirtual inheritance, base classes are constructed in the order in which they are named in the class derivation list. Under virtual inheritance, the virtual base class(es) are constructed before any other bases. They are constructed in the order in which they appear in the derivation list of the derived type. Only the most derived type may initialize a virtual base; constructor initializers for that base that appear in the intermediate base classes are ignored.
exception declaration
catch
clause declaration that specifies the type of exception that thecatch
can handle. The declaration acts like a parameter list, whose single parameter is initialized by the exception object. If the exception specifier is a nonreference type, then the exception object is copied to thecatch
.
exception handling Language-level support for managing run-time anomalies. One independently developed section of code can detect and “raise” an exception that another independently developed part of the program can “handle.” The error-detecting part of the program throws an exception; the error-handling part handles the exception in a
catch
clause of atry
block.
exception object Object used to communicate between the
throw
andcatch
sides of an exception. The object is created at the point of thethrow
and is a copy of the thrown expression. The exception object exists until the last handler for the exception completes. The type of the object is the static type of the thrown expression.
file static Name local to a file that is declared with the
static
keyword. In C and pre-Standard versions of C++, file statics were used to declare objects that could be used in a single file only. File statics are deprecated in C++, having been superseded by the use of unnamed namespaces.
function try block Used to catch exceptions from a constructor initializer. The keyword
try
appears before the colon that starts the constructor initializer list (or before the open curly of the constructor body if the initizlier list is empty) and closes with one or morecatch
clauses that appear after the close curly of the constructor body.
global namespace The (implicit) namespace in each program that holds all global definitions.
handler Synonym for a
catch
clause.
inline namespace Members of a namespace designated as
inline
can be used as if they were members of an enclosing namespace.
multiple inheritance Class with more than one direct base class. The derived class inherits the members of all its base classes. A separate access specifier may be provided for each base class.
namespace Mechanism for gathering all the names defined by a library or other collection of programs into a single scope. Unlike other scopes in C++, a namespace scope may be defined in several parts. The namepsace may be opened and closed and reopened again in disparate parts of the program.
namespace alias Mechanism for defining a synonym for a given namespace:
namespace N1 = N;
defines
N1
as another name for the namespace namedN
. A namespace can have multiple aliases; the namespace name or any of its aliases may be used interchangeably.
namespace pollution Occurs when all the names of classes and functions are placed in the global namespace. Large programs that use code written by multiple independent parties often encounter collisions among names if these names are global.
noexcept operator Operator that returns a
bool
indicating whether a given expression might throw an exception. The expression is unevaluated. The result is a constant expression. Its value istrue
if the expression does not contain athrow
and calls only functions designated as nonthrowing; otherwise the result isfalse
.
noexcept specification Keyword used to indicate whether a function throws. When
noexcept
follows a function’s parameter list, it may be optionally followed by a parenthesized constant expression that must be convertible tobool
. If the expression is omitted, or if it istrue
, the function throws no exceptions. An expression that isfalse
or a function that has no exception specification may throw any exception.
nonthrowing specification An exception specification that promises that a function won’t throw. If a nonthrowing functions does throw,
terminate
is called. Nonthrowing specifiers arenoexcept
without an argument or with an argument that evaluates astrue
andthrow()
.
raise Often used as a synonym for throw. C++ programmers speak of “throwing” or “raising” an exception interchangably.
rethrow A
throw
that does not specify an expression. A rethrow is valid only from inside acatch
clause, or in a function called directly or indirectly from acatch
. Its effect is to rethrow the exception object that it received.
stack unwinding The process whereby the functions are exited in the search for a
catch
. Local objects constructed before the exception are destroyed before entering the correspondingcatch
.
terminate Library function that is called if an exception is not caught or if an exception occurs while a handler is in process.
terminate
ends the program.
throw e Expression that interrupts the current execution path. Each
throw
transfers control to the nearest enclosingcatch
clause that can handle the type of exception that is thrown. The expressione
is copied into the exception object.
try block Block of statements enclosed by the keyword
try
and one or morecatch
clauses. If the code inside thetry
block raises an exception and one of thecatch
clauses matches the type of the exception, then the exception is handled by thatcatch
. Otherwise, the exception is passed out of thetry
to acatch
further up the call chain.
unnamed namespace Namespace that is defined without a name. Names defined in an unnamed namespace may be accessed directly without use of the scope operator. Each file has its own unique unnamed namespace. Names in an unnamed namespace are not visible outside that file.
using declaration Mechanism to inject a single name from a namespace into the current scope:
using std::cout;
makes the name
cout
from the namespacestd
available in the current scope. The namecout
can subseuquently be used without thestd::
qualifier.
using directive Declaration of the form
using NS;
makes all the names in the namespace named
NS
available in the nearest scope containing both theusing
directive and the namespace itself.
virtual base class Base class that specifies
virtual
in its own derivation list. A virtual base part occurs only once in a derived object even if the same class appears as a virtual base more than once in the hierarchy. In nonvirtual inheritance a constructor may initialize only its direct base class(es). When a class is inherited virtually, that class is initialized by the most derived class, which therefore should include an initializer for all of its virtual parent(s).
virtual inheritance Form of multiple inheritance in which derived classes share a single copy of a base that is included in the hierarchy more than once.
::
operator Scope operator. Used to access names from a namespace or a class.