What you will learn in 100 C++ Mistakes and How to Avoid Them
Chapter by chapter
Concepts explained in this book
- invariantA class invariant is a condition on an object's state that must hold whenever the object is usable, including after construction and public operations.
- initializerA constructor is a C++ member function that initializes an object when an instance of its class is created.
- resource acquisition is initializationRAII is a C++ resource-management idiom that binds resource lifetime to the lifetime of an object.
- exceptionAn exception is a C++ control-flow mechanism that transfers execution to error-handling code when an exceptional condition occurs.
- copy assignment operatorA copy assignment operator is a C++ special member function that assigns the state of one existing object to another existing object of the same or compatible class.
- inheritanceInheritance is a C++ language mechanism by which a derived class acquires and can extend members and behavior from base classes.
- destructorA destructor is a C++ special member function that runs when an object is destroyed to release owned resources and perform cleanup.
- copy constructorA copy constructor is a C++ special member function that initializes an object from another object of the same class by copying its state.
- accessor methodAn accessor is a class member function that provides access to an object's state without defining the object's state-changing operation.
- polymorphismPolymorphism is the ability to use a common interface while selecting behavior according to an object's actual type.
- exclusive ownershipExclusive ownership is a resource-management property in which exactly one object or owner is responsible for a resource at a time.
- vectorA vector is a resizable sequence container whose elements are stored in contiguous memory.
- default constructorA default constructor is a constructor that can initialize an object without requiring caller-supplied arguments.
- undefined behaviorUndefined behavior is a program operation whose result or behavior is not defined by the applicable language standard.
- scopeScope is the region of a C++ program in which a declared name can be accessed.
- resource managementResource management is the coordinated acquisition, use, and release of resources such as memory, files, sockets, or database connections.
- smart pointerA smart pointer is a C++ pointer-like object that manages the lifetime of a dynamically allocated resource according to an ownership policy.
- std::unique_ptrstd::unique_ptr is a C++ standard-library smart pointer that provides exclusive ownership of a dynamically allocated object or array and automatically manages its lifetime.
- resource leakA resource leak is a failure to release an acquired resource, leaving it allocated or unavailable for reuse.
- stream insertion operatorThe stream insertion operator, written operator<< in C++, is an overloaded operator used to write formatted values to an output stream such as std::ostream.
- move constructorA move constructor is a C++ special member function that initializes an object by transferring resources from a source object.
- memory leakA memory leak is a failure to release dynamically allocated storage after it is no longer accessible or needed.
- classA class is a C++ language construct that defines a user-defined type containing data members and member functions with specified access control.
- arrayAn array is a fixed-layout sequence of elements accessed by position through an index.
- return value optimizationReturn value optimization is a compiler optimization that constructs a function's returned object directly in the destination storage, eliminating unnecessary temporary objects and copy operations.
- namespaceThe global namespace is the C++ namespace containing declarations that are not enclosed in another namespace.
- booleanA Boolean value represents one of two logical states, conventionally false and true.
- move assignment operatorA move assignment operator is a C++ special member function that transfers resources from a source object into an already existing target object.
- initializationInitialization is the process of giving a C++ object its initial value or state when it is created.
- function templateA function template is a C++ template that defines a family of functions generated for specific argument or type combinations.
- operation basisA basis is a minimal set of essential, nonoverlapping functions from which other functions can be implemented.
- ranges APIThe C++ ranges API is a standard-library interface for applying algorithms to ranges of elements without requiring explicit iterator pairs.
- usability metricEffectiveness is a measure of how well language features are applied for their intended purposes to reduce development effort.
- deep copyDeep copy semantics create independent copies of dynamically owned or referenced resources rather than sharing the same resource.
- data conversionThe transformation of a value or object representation from one data type to another, either implicitly or explicitly requested.
- implicit conversionAn automatic conversion performed by C++ without an explicit cast or conversion request in the source code.
- std::shared_ptrstd::shared_ptr is a C++ standard-library smart pointer that maintains shared ownership of a dynamically allocated object through reference counting.
- encapsulationEncapsulation is the software design principle of containing an entity's data and behavior within its representation and controlling access to that representation.
- public inheritancePublic inheritance is C++ inheritance in which the public and protected members of a base class retain their corresponding accessibility in the derived class.
- printfprintf is a C standard-library function that formats values and writes the resulting text to an output stream.
- construction orderConstruction order is the language-defined ordering in which base-class and derived-class subobjects are initialized when an object is created.
- destruction orderDestruction order is the language-defined ordering in which class subobjects and their destructors are processed when an object is destroyed.
- validation methodA validation method is a function that checks an input value against required conditions and returns a valid value or reports failure.
- auto_ptrstd::auto_ptr was a deprecated and removed C++ standard-library smart pointer with transfer-on-copy ownership behavior.
- virtual methodA virtual function is a C++ member function whose implementation can be dynamically selected through an object of a derived class.
- filteringFiltering is a data-processing operation that retains or rejects each input element according to a predicate.
- std::movestd::move is a C++ standard library function template that casts an expression to an rvalue reference to enable move operations.
- superclassA base class is a C++ class from which another class inherits members and behavior.
- autoauto is a C++ declaration specifier that asks the compiler to deduce a variable's type from its initializer.
- global variableA global variable is a variable declared at global or namespace scope whose visibility can extend across functions within a compilation unit.
- scope resolution operatorThe C++ scope resolution operator :: qualifies a name to select a declaration from a specified namespace, class, or scope.
- shadowingVariable shadowing occurs when a declaration in an inner scope uses the same name as a declaration in an outer scope, hiding the outer declaration within the inner scope.
- this pointerThe this pointer is the implicit pointer available in a non-static C++ member function that refers to the object on which the function was invoked.
- content shadowingContent shadowing is a variable-shadowing error in which code uses an inner variable when the corresponding outer variable was intended.
- intent shadowingIntent shadowing is a semantic error in which similarly named variables representing related meanings are confused even when their scopes do not cause actual name hiding.
- base class arrayA base class array is an array whose elements have a base class type and whose indexing uses that type's size.
- derived class arrayA derived class array is an array whose elements have a class type derived from another class and whose layout may be larger than the base class layout.
- pointer arithmeticPointer arithmetic is the calculation of pointer values by adding or subtracting element-based offsets.
- polymorphic array elementA polymorphic array element is an array element accessed through a base-class array interface even though the stored elements have a derived class type.
- CC is a general-purpose procedural programming language that provides low-level memory and systems programming capabilities.
- pure virtual member functionA pure virtual function is a C++ virtual member function declared without a required implementation in the declaring class and intended to be overridden by derived classes.
- zero valueA zero value is the type-dependent zero-initialized value assigned to an object or variable by a relevant initialization operation.
- virtual destructorA virtual destructor is a destructor declared virtual so destruction through a base-class interface dispatches to the derived object's destructor.
- const referenceA const reference is a C++ reference whose access path prevents modification of the referred-to object.
- temporary objectA temporary object is an unnamed object created for an intermediate expression or value and typically given a limited lifetime.
- std::stringstreamstd::stringstream is a C++ standard-library stream class that supports formatted input and output through an in-memory character sequence.
- initializer listAn initializer list is a sequence of initialization elements supplied using brace syntax to initialize objects, constructors, or containers.
- big fiveThe rule of five is a C++ class-design pattern in which a class considers defining a destructor, copy constructor, copy assignment operator, move constructor, and move assignment operator together.
- member-wise copyMember-wise copy is the operation of copying an object's individual data members from a source object to a target object.
- streamingA stream is an interface that represents a sequential flow of data between a program and an input or output source.
- deletedelete is a C++ expression that destroys an object and releases storage allocated by a compatible new expression.
- new operatornew is a C++ expression that allocates storage and constructs an object of the requested type.
- immutable collectionImmutable data is data whose value cannot be changed after it has been created.
- rational numberA rational number is a number expressible as a ratio of two integers with a nonzero denominator.
- exception specificationA C++ declaration mechanism that specifies which exceptions a function may throw.
- type inferenceType inference is the compiler's process of determining a program entity's type from available declarations, initializers, or contextual information.
- delta-epsilon methodThe delta-epsilon method compares floating-point values by accepting a difference within a chosen tolerance rather than requiring exact equality.
- floating-point arithmeticA floating-point value is a numeric representation that approximates a real number using a finite-precision significand and exponent.
- run-time polymorphismRuntime polymorphism is the selection of an overridden operation according to an object's dynamic type during execution.
- vtableA virtual function table is a compiler-generated table containing addresses used to dispatch a class's virtual functions.
- loopA for loop is a C++ loop construct that places initialization, continuation testing, and iteration update in its control statement around a loop body.
- rvalue referenceAn rvalue reference is a C++ reference type that can bind to temporary or otherwise movable expressions and enable resource transfer.
- predicateA predicate is a Boolean-valued function that determines whether a value satisfies a condition.
- conversion constructorA constructor that can convert an argument of another type into an object of its class type, especially when it has one parameter.
- deleted functionThe C++ delete specifier marks a function or class member as unavailable so that attempts to provide or use it are diagnosed at compile time.
- big threeThe big 3 is the C++ special-member-function set consisting of a copy constructor, copy assignment operator, and destructor.
- protected memberA protected member is a class member accessible from the class and its derived classes, subject to C++ access rules, but not generally from unrelated client code.
- self-assignmentSelf-assignment is assigning an object to itself through an assignment operator.
- boost::scoped_ptrboost::scoped_ptr is a Boost smart pointer that provides exclusive ownership of a dynamically allocated object and prevents ownership transfer by assignment.
- prefix increment operatorThe prefix form of the increment operator increases its operand before producing the expression's result.
- iteratorAn iterator is a C++ library object that provides a uniform means of traversing and accessing elements in a range or container.
- code divergenceThe condition in which duplicated implementations become inconsistent because changes are applied to one copy but not another.
- don't repeat yourself principleThe DRY principle is the software design principle of avoiding repeated knowledge or behavior across multiple implementations.
- double delete errorA double free is an error in which the same allocated resource is deallocated more than once.
- variadic templateA variadic template is a C++ template that accepts a variable number of template arguments or function arguments.
- abstract classAn abstract base class is a C++ base class intended to define behavior for derived classes and not to be instantiated directly.
- C++ standard libraryThe Standard Template Library is the C++ standard library collection of generic containers, algorithms, iterators, and related components.
- uniform initializationUniform initialization is C++ initialization syntax using braces that provides consistent initialization semantics and rejects narrowing conversions.
- regular expressionA regular expression is a formal pattern specification for recognizing, extracting, or substituting portions of text.
- catch by referenceCatch by reference is the C++ exception-handling technique of binding a handler parameter to the thrown exception through a reference.
- throw by valueThrow by value is the C++ exception-handling technique of throwing an exception object as a value rather than as a pointer or reference.
- range-based for loopA range-based for loop is a C++ iteration statement that traverses the elements of a range or container without explicit index management.
- range adapterA range adapter is a C++ standard-library component that creates a view of a range by applying a lazy transformation or selection operation.
- std::accumulatestd::accumulate is a C++ standard-library algorithm that folds a range of values into one result using an initial value and an accumulation operation.
- std::views::filterstd::views::filter is a C++ standard-library range adaptor that lazily exposes elements satisfying a supplied predicate.
- std::views::transformstd::views::transform is a C++ standard-library range adaptor that lazily maps each element of a range through a supplied function.
- extraction operatorThe extraction operator is the overloaded C++ operator>> used to read and convert formatted data from an input stream.
- scanf familyscanf is a C standard-library function that reads formatted input from a stream and converts it according to a format string.
- undefined valueAn undefined value is a value whose contents have not been established by the program and therefore have no known intended meaning.
- implementation detailAn implementation detail is an internal representation or mechanism of a component that is not part of its intended external contract.
- C-style formattingC-style formatting is output construction based on a format string containing conversion directives and corresponding arguments.
- std::formatstd::format is a C++ standard-library function that produces a formatted string from a format string and typed arguments.
- static keywordThe static specifier is a C++ declaration specifier that gives a class member static storage or class-level rather than object-level association, depending on context.
- static methodA static member function is a C++ member function associated with a class rather than a particular object and therefore unable to access non-static instance state.
- constexprconstexpr is a C++ specifier that permits a variable or function to participate in compile-time constant evaluation when its requirements are satisfied.
- preprocessorA preprocessor is a source-processing component that transforms code, including performing macro substitution, before compilation.
- unique objectA unique object is an object whose identity or existence must not be duplicated within the modeled domain.
- backing arrayA backing array is the dynamically managed array that provides storage for a resizable vector.
- apply operatorThe apply operator is the C++ call operator that defines how an object is invoked with function-call syntax.
- tupleA tuple is a fixed-size aggregate that stores values of potentially different types in a specified order without requiring user-supplied field names.
- make_uniquestd::make_unique is a C++ standard-library function template that creates and returns a std::unique_ptr with exception-safe allocation and construction.
- ownership transferOwnership transfer is the operation of changing which object is responsible for managing a resource.
- immutable instance variableAn immutable instance variable is a data member whose value cannot be changed after its initialization.
- trivial mutatorA trivial mutator is a state-changing member function that directly assigns an input value to an instance variable without enforcing relevant constraints.
- size_tsize_t is an unsigned integer type capable of representing the size of any object in C++.
- virtual keywordThe C++ virtual specifier declares a member function as participating in virtual dispatch and signals that a class is intended to support inheritance-based polymorphism.
- warning checkingWarning checking is the practice of enabling compiler diagnostics to identify potentially erroneous or problematic code during compilation.
- warnings as errorsWarnings as errors is a compiler configuration that treats diagnostic warnings as build-blocking errors.
- off-by-one errorAn off-by-one error is a boundary error in which an iteration or index range includes one element too many or too few.
- std::unexpectedstd::unexpected is a deprecated C++ function invoked when an exception violates a dynamic exception specification.
- circular referenceA circular reference is a cycle of object references in which objects eventually refer back to an earlier object in the cycle.
- const_castconst_cast is a C++ cast expression that adds or removes constness or volatility from an expression's type.
- dynamic_castdynamic_cast is a C++ run-time checked cast expression for converting within polymorphic class hierarchies or testing such conversions.
- reinterpret_castreinterpret_cast is a C++ cast expression that reinterprets the representation of an object or pointer as another type without performing a normal value conversion.
- static_caststatic_cast is a C++ cast expression that performs compile-time checked conversions between related or otherwise compatible types.
- pattern matchingPattern matching is the process of determining whether structured data conforms to a specified pattern.
- raw string literalA raw string is a C++ string literal whose contents are written without interpreting ordinary escape sequences.
- friend functionA friend function is a nonmember C++ function granted access to a class's private and protected members.
- nonmember functionA nonmember function is a C++ function defined outside a class and not belonging to any class instance.
- enumAn enumeration is a C++ type that defines a set of named integral values representing a finite collection of alternatives.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
