Skip to content
UPEEC

Object-Oriented C++

Classes, special member functions, inheritance, polymorphism and run-time type information. Classes and objects, constructors and destructors, copy/move semantics, inheritance, virtual functions and abstract classes have their own pages earlier in this subject.

Easy
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (13)

Copy Constructor

`T(const T& other)` creates a new object as a copy.

Easy♥ 0🔖 0💬 0

Move Constructor

`T(T&& other) noexcept` transfers resources from a temporary instead of copying.

Intermediate♥ 0🔖 0💬 0

Copy Assignment

`T& operator=(const T& other)` replaces an existing object's contents with a copy.

Intermediate♥ 0🔖 0💬 0

Move Assignment

`T& operator=(T&& other) noexcept` replaces contents by stealing from a temporary.

Intermediate♥ 0🔖 0💬 0

Polymorphism in C++

One interface, many implementations: compile-time (templates, overloading) and run-time (virtual functions).

Easy♥ 0🔖 0💬 0

Encapsulation

Hide data behind `private`/`protected` and expose a minimal `public` interface.

Beginner♥ 0🔖 0💬 0

Nested Classes

A class defined inside another — scoped to it, often for helpers like iterators or nodes.

Easy♥ 0🔖 0💬 0

Static Members

Members shared by all objects of a class.

Easy♥ 0🔖 0💬 0

RTTI

Run-Time Type Information: `typeid` and `dynamic_cast` on polymorphic types.

Intermediate♥ 0🔖 0💬 0

dynamic_cast

Safely downcast a base pointer/reference to a derived type, checking at run time.

Intermediate♥ 0🔖 0💬 0

Virtual Destructors

A base class used polymorphically needs a `virtual` destructor.

Intermediate♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.