π§ C++ Modules β 1337 / 42 Network Journey
Welcome to my C++ modules journey, completed as part of the 1337/42 Curriculum.
This repository documents my understanding and progress through C++ Modules 00 β 09, focusing on object-oriented programming, templates, STL, and modern C++ techniques.
π What is Object-Oriented Programming (OOP)?
Object-Oriented Programming (OOP) is a paradigm where software is structured around objects rather than actions. Objects are instances of classes, which are blueprints for organizing both data and behavior.
π Core OOP Principles:
| Concept | Description |
|---|
| Class | A blueprint that defines attributes and methods for objects. |
| Object | An instance of a class β holds real data and behavior. |
| Encapsulation | Bundling of data and the methods that operate on that data. |
| Inheritance | A class can inherit members and methods from another class. |
| Polymorphism | Different objects can be treated through the same interface, behaving differently. |
| Abstraction | Hiding complex details and showing only the essentials. |
π¦ Module Breakdown & Key Concepts
π₯ Module 00 β Basics of C++
π Topics Covered:
- Namespaces: Used to prevent name conflicts in large projects. (e.g.,
std)
- Classes & Objects: Core building blocks of OOP. A class is a blueprint; an object is a usable instance.
- Member Functions: Functions that belong to a class and operate on its data.
- stdio Streams:
cout, cin, and cerr are used for input/output in C++.
- Initialization Lists: A concise way to initialize members in a constructor.
- Static: A static member is shared across all instances of a class.
- Const: Makes variables read-only or ensures a method doesnβt modify the object.
β
Skills Acquired:
- Building basic classes and objects.
- Applying access specifiers (
private, public, protected).
- Writing constructors, destructors, and initialization lists.
- Differentiating between static vs instance members.
- Using const-correctness in class design.
π₯ Module 01 β Memory & Pointers
π Topics Covered:
- Memory Allocation: Using
new and delete to manage dynamic memory.
- Pointers to Members: Special pointer syntax to refer to class members.
- References: An alias to another variable (safer alternative to pointers).
- Switch Statement: A control flow construct to handle multiple conditions efficiently.
β
Skills Acquired:
- Allocating and freeing heap memory.
- Understanding the difference between stack and heap memory.
- Using pointers and references effectively.
- Applying switch-case logic to manage complex decision trees.
π₯ Module 02 β Operator Overloading & Canonical Form
π Topics Covered:
-
Ad-hoc Polymorphism: Achieved using function/operator overloading.
-
Operator Overloading: Custom behavior for operators like +, <<, ==, etc.
-
Orthodox Canonical Form:
- Default constructor
- Copy constructor
- Copy assignment operator
- Destructor
β
Skills Acquired:
- Implementing overloaded operators for custom types.
- Ensuring proper memory handling via Rule of Three.
- Building copy-safe and assignable classes.
- Understanding deep vs shallow copies.
π₯ Module 03 β Inheritance
π Topics Covered:
- Inheritance: Deriving a new class from an existing one.
- Access Specifiers in inheritance (
public, protected, private).
- Constructor chaining: Calling base class constructors in derived classes.
β
Skills Acquired:
- Building class hierarchies.
- Reusing and extending functionality using inheritance.
- Understanding object slicing and how to avoid it.
- Designing more modular and testable code.
π₯ Module 04 β Abstract Classes & Interfaces
π Topics Covered:
- Subtype Polymorphism: Using base class pointers/references to handle derived types.
- Virtual Functions: Enables runtime polymorphism.
- Abstract Classes: Classes with at least one pure virtual function (
= 0).
- Interfaces: Pure abstract classes that define a contract.
β
Skills Acquired:
- Implementing dynamic polymorphism.
- Designing interfaces and abstract hierarchies.
- Writing polymorphic code that is flexible and extendable.
- Understanding the role of virtual destructors.
π₯ Module 05 β Exceptions & Error Handling
π Topics Covered:
- try / catch / throw: Basic exception handling constructs.
- Exception Safety: Writing code that stays safe under failure.
- RAII: Pattern to manage resources automatically via object lifetime.
β
Skills Acquired:
- Catching and throwing exceptions cleanly.
- Designing exception-safe constructors and destructors.
- Managing resources using RAII to avoid leaks.
- Differentiating between recoverable and non-recoverable errors.
π₯ Module 06 β Type Casting in C++
π Topics Covered:
- static_cast: Compile-time type conversion.
- dynamic_cast: Runtime type-safe downcasting (needs polymorphism).
- const_cast: Removing
const/volatile qualifiers.
- reinterpret_cast: Bit-level conversion; very low-level and unsafe.
β
Skills Acquired:
- Choosing the right cast for the right context.
- Understanding cast limitations and dangers.
- Writing cleaner and safer conversion code.
- Debugging with proper use of dynamic_cast.
π₯ Module 07 β Templates
π Topics Covered:
- Function Templates: Generic functions that work with any type.
- Class Templates: Classes that take types as parameters.
- Template Instantiation: Compiler-generated code for used types.
β
Skills Acquired:
- Writing and using generic code.
- Creating reusable containers and algorithms.
- Understanding the cost of template bloat.
- Exploring template specialization and SFINAE.
π₯ Module 08 β Containers, Iterators, and Algorithms
π Topics Covered:
- Templated Containers:
map, stack, vector, deque, list, etc.
- Iterators: Objects for traversing containers.
- STL Algorithms:
sort, find, lower_bound count, for_each, etc.
β
Skills Acquired:
- Navigating and manipulating STL containers.
- Writing efficient loops with iterators.
- Using algorithms to write expressive and high-level logic.
- Integrating lambda functions with STL.
π₯ Module 09 β STL (Standard Template Library)
π Topics Covered:
- Containers:
map, stack, vector, deque, list, etc.
- Iterators:
begin(), end(), rbegin(), rend()
- Algorithms:
sort, find, lower_bound count, for_each, etc.
- Utilities:
pair, function, bind, tuple
β
Skills Acquired:
- Mastering STL components.
- Writing idiomatic, high-level C++.
- Leveraging generic programming and composability.
- Building expressive, readable, and maintainable code.
π To explore the Merge-Insertion Sort (Ford-Johnson Algorithm) built as part of this module, check out the implementation here: Ford-Johnson Algorithm Repo
π Final Thoughts
Completing these modules gave me a rock-solid foundation in modern C++.
From mastering OOP, to leveraging templates and STL, every concept brought me one step closer to becoming a proficient, confident developer.
Check the /exXX/ folders for my implementations.
π¨ Feel free to reach out, contribute, or ask me anything!
π§βπ» Author: Samir Ouaammou
π 1337 School / 42 Network
π Passionate about C++, Linux, and clean code!