Page Background Animation
233 words
1 minute
C++ Modules (00–09) — OOP, Memory Semantics, Templates & STL

C++ Modules (00 through 09)#

The C++ modules in the 1337 / 42 curriculum transition from procedural C to object-oriented programming, generic metaprogramming, and STL container algorithms under the C++98 standard.

Curriculum Breakdown#

ModuleTimelineCore Focus
CPP 00–0110 months agoNamespaces, classes, member functions, references, memory allocation (new/delete).
CPP 02–039 months agoOrthodox Canonical Class Form, fixed-point representation, operator overloading, class inheritance.
CPP 04–058 months agoSubtype polymorphism, abstract interfaces, custom exception hierarchies (std::exception).
CPP 06–077 months agoC++ cast operators (static_cast, dynamic_cast, const_cast, reinterpret_cast), function & class templates.
CPP 0811 days agoTemplated containers, iterators, and generic algorithms (std::span, easyfind).
CPP 092 days agoSTL algorithms: Bitcoin exchange parsing, Reverse Polish Notation calculator, Ford-Johnson merge-insertion sort (PmergeMe).

Implementation Details#

1. Orthodox Canonical Class Form (OCF)#

All classes follow strict copy and memory ownership semantics:

class Subject
{
public:
Subject(); // Default constructor
Subject(const Subject &other); // Copy constructor
Subject &operator=(const Subject &rhs); // Copy assignment operator
virtual ~Subject(); // Virtual destructor
};

2. Abstract Interfaces & Polymorphism#

Decoupled class hierarchies implemented via pure virtual functions:

class ICharacter
{
public:
virtual ~ICharacter() {}
virtual std::string const &getName() const = 0;
virtual void equip(AMateria *m) = 0;
virtual void unequip(int idx) = 0;
virtual void use(int idx, ICharacter &target) = 0;
};

3. Module 09: Ford-Johnson Merge-Insertion Sort (PmergeMe)#

Implements the Ford-Johnson sorting algorithm to minimize comparisons:

  • Recursively pairs and sorts elements.
  • Inserts un-paired elements using Jacobsthal-number-guided binary insertion sequences.
  • Benchmarked across std::vector and std::deque with identical sorted outputs.

Standards and Verification#

  • Compiled with -Wall -Wextra -Werror -std=c++98.
  • Validated with zero memory leaks via Valgrind.