Advanced Class Concepts and Techniques Terminology Reference

This reference provides an overview of advanced class terminology you'll encounter in this chapter. Use it as a quick lookup guide.

The this Pointer

Term Definition Example
this Pointer Hidden pointer to current object in member function this->member accesses current object's member
Implicit Object Object on which member function is called In obj.func(), obj is implicit object
Member Function Chaining Returning *this to enable chained calls obj.setX(5).setY(10);
Fluent Interface API design using method chaining Multiple operations in one statement

Class Organization

Term Definition Example
Header File File containing class declaration ClassName.h with class definition
Implementation File File containing member function definitions ClassName.cpp with implementations
Class Declaration Class interface in header Public/private members declared
Member Function Definition Implementation of class method Full function body in .cpp file
Include Guard Prevents multiple inclusion of header #pragma once or #ifndef

Nested Types

Term Definition Example
Nested Type Type defined inside a class class Outer { enum Type { A, B }; };
Member Type Another name for nested type Type scoped to class
Scope Resolution Accessing nested type with :: Outer::Type myType = Outer::A;
Type Encapsulation Keeping type definition inside related class Type only relevant to containing class

Destructors

Term Definition Example
Destructor Special function called when object is destroyed ~ClassName()
RAII Resource Acquisition Is Initialization pattern Constructor acquires, destructor releases
Resource Cleanup Releasing resources in destructor Closing files, freeing memory
Automatic Cleanup Destructor called automatically at end of lifetime No manual intervention needed
Destructor Order Destructors called in reverse construction order Last constructed, first destroyed

Class Templates with Members

Term Definition Example
Template Member Function Member function of class template Methods that use template parameters
Template Method Member function defined outside class Must include template syntax
Template Class Definition Complete class template implementation Template parameters and members
Member Function Template Template member in non-template class Individual method is templated

Static Members

Term Definition Example
Static Member Variable Variable shared by all class instances One copy for entire class
Class Variable Another name for static member variable Belongs to class, not instances
Static Initialization Defining static member outside class int MyClass::count{0};
Static Member Access Accessing via class name or instance MyClass::count or obj.count

Static Member Functions

Term Definition Example
Static Member Function Function that doesn't operate on instance No this pointer available
Class Method Function callable without object instance MyClass::staticFunc();
Static Context Environment without access to instance members Cannot use non-static members
Utility Function Common use for static member functions Helper functions related to class

Friend Declarations

Term Definition Example
Friend Function Non-member function with private member access Can access private/protected members
Friend Declaration Statement granting friendship friend void func(MyClass&);
Non-Member Function Function not part of class Defined outside class
Privileged Access Ability to access private members Friends bypass access restrictions

Friend Classes and Members

Term Definition Example
Friend Class Class with access to another class's private members friend class OtherClass;
Friend Member Function Specific member of another class granted access friend void Other::func(MyClass&);
Bidirectional Friendship Two classes granting each other friend access Both classes friend each other
Asymmetric Friendship Friendship is not automatically reciprocal A friends B doesn't make B friend A

Ref Qualifiers

Term Definition Example
Ref Qualifier Specifies if method works on lvalue or rvalue void func() & or void func() &&
Lvalue Qualifier Method callable only on lvalue objects void func() &
Rvalue Qualifier Method callable only on rvalue objects void func() &&
Overload on Value Category Different implementations for lvalue/rvalue Optimized move for temporaries

Access Control

Term Definition Example
Encapsulation Hiding implementation details Private members, public interface
Information Hiding Restricting access to internals Users don't see private implementation
Class Invariant Condition that must always be true Account balance cannot be negative
Interface Public members users can access Public methods defining how to use class

Object Lifetime

Term Definition Example
Construction Creating and initializing object Constructor called
Destruction Cleaning up object at end of lifetime Destructor called
Automatic Storage Objects created on stack Local variables in functions
Object Scope Region where object exists From declaration to end of block

Advanced Patterns

Term Definition Example
Factory Function Static function that creates objects static MyClass create(int x);
Singleton Pattern Class with only one instance Static instance, private constructor
Builder Pattern Class for constructing complex objects Method chaining to set properties
Pimpl Idiom Pointer to implementation for hiding details Forward declaration with unique_ptr