This reference provides an overview of object-oriented programming terminology you'll encounter in this chapter. Use it as a quick lookup guide.

Classes and Objects

Term Definition Example
Class User-defined type with data and functions class Player { };
Object Instance of a class Player p1;
Instance Synonym for object Each object is an instance
Instantiation Creating an object from a class Player player{};
Member Data or function belonging to a class Variables and methods inside class
struct Class with public members by default struct Point { int x; int y; };

Member Variables

Term Definition Example
Member variable Data stored in each object int m_health;
Data member Synonym for member variable Fields of a class
Attribute Another term for member variable Properties of an object
m_ prefix Convention for member variable names m_name, m_score
Instance variable Member variable unique to each object Each object has its own copy

Member Functions

Term Definition Example
Member function Function belonging to a class void attack() { }
Method Synonym for member function Operations an object can perform
this pointer Pointer to the current object this->m_health
Implicit object Object on which method is called player.attack() - player is implicit
const member function Method that doesn't modify the object int getHealth() const

Access Control

Term Definition Example
Access specifier Keyword controlling member visibility public:, private:, protected:
public Accessible from anywhere Interface of the class
private Accessible only within the class Implementation details
protected Accessible in class and derived classes For inheritance
Encapsulation Hiding implementation details Private data, public interface
Information hiding Restricting direct access to data Using private members

Getters and Setters

Term Definition Example
Getter Function returning member value int getHealth() const { return m_health; }
Setter Function setting member value void setHealth(int h) { m_health = h; }
Accessor Synonym for getter Read-only access to data
Mutator Synonym for setter Modifies object state
Access function General term for getter/setter Methods for member access

Constructors

Term Definition Example
Constructor Special function for object initialization Player() { }
Default constructor Constructor with no parameters Player() = default;
Parameterized constructor Constructor with parameters Player(int health) { }
Member initializer list Efficient member initialization Player() : m_health{100} { }
Default member initializer In-class member initialization int m_health{100};
Implicit constructor Compiler-generated constructor Auto-generated if none provided
Explicit constructor Prevents implicit conversions explicit Player(int id)
Delegating constructor Constructor calling another Player() : Player{100} { }

Destructors

Term Definition Example
Destructor Special function for cleanup ~Player() { }
RAII Resource Acquisition Is Initialization Manage resources via object lifetime
Automatic cleanup Destructor called when object goes out of scope No manual cleanup needed

Object Lifetime

Term Definition Example
Construction When object is created Memory allocated, constructor called
Destruction When object is destroyed Destructor called, memory freed
Scope-based lifetime Object destroyed at end of scope Local objects in functions
Temporary object Object created for expression evaluation Return values, casts

Copy Semantics

Term Definition Example
Copy constructor Creates object as copy of another Player(const Player& other)
Copy assignment Assigns one object to another Player& operator=(const Player&)
Shallow copy Copies pointer values, not pointed data Default copy behavior
Deep copy Copies the actual data Required for pointer members
Copy elision Compiler optimization avoiding copies Return value optimization

Class Design

Term Definition Example
Interface Public members visible to users What the class can do
Implementation Private details of how it works Hidden from users
Invariant Condition that must always be true Health is never negative
Abstract data type Type defined by operations, not implementation Stack, Queue concepts
Aggregate Class with no constructors, all public Simple data holder

Special Members

Term Definition Example
Static member Shared by all instances of class static int s_count;
Static member function Function not tied to an instance static int getCount()
Friend Non-member with access to private members friend void helper();
Nested class Class defined inside another class Inner helper classes

Object Relationships

Term Definition Example
Composition Object owns another object Car has an Engine
Aggregation Object references another object Team has Players
Association Objects use each other Player uses Weapon
Dependency Object temporarily uses another Function parameter

Best Practices

Term Definition Example
Single responsibility Class should have one purpose Player handles player logic only
Minimal interface Expose only what's necessary Keep most members private
Const correctness Use const where appropriate Const getters, const parameters
Rule of Zero Prefer no special member functions Use RAII wrapper types
Rule of Three/Five Define all or none of copy/move ops If you need one, define all