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.
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.
| 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. |
- 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, andcerrare 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.
- 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.
- Memory Allocation: Using
newanddeleteto 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.
- 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.
-
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
- 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.
- 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.
- Building class hierarchies.
- Reusing and extending functionality using inheritance.
- Understanding object slicing and how to avoid it.
- Designing more modular and testable code.
- 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.
- Implementing dynamic polymorphism.
- Designing interfaces and abstract hierarchies.
- Writing polymorphic code that is flexible and extendable.
- Understanding the role of virtual destructors.
- 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.
- 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.
- static_cast: Compile-time type conversion.
- dynamic_cast: Runtime type-safe downcasting (needs polymorphism).
- const_cast: Removing
const/volatilequalifiers. - reinterpret_cast: Bit-level conversion; very low-level and unsafe.
- 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.
- 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.
- Writing and using generic code.
- Creating reusable containers and algorithms.
- Understanding the cost of template bloat.
- Exploring template specialization and SFINAE.
- Templated Containers:
map,stack,vector,deque,list, etc. - Iterators: Objects for traversing containers.
- STL Algorithms:
sort,find,lower_boundcount,for_each, etc.
- Navigating and manipulating STL containers.
- Writing efficient loops with iterators.
- Using algorithms to write expressive and high-level logic.
- Integrating lambda functions with STL.
- Containers:
map,stack,vector,deque,list, etc. - Iterators:
begin(),end(),rbegin(),rend() - Algorithms:
sort,find,lower_boundcount,for_each, etc. - Utilities:
pair,function,bind,tuple
- 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
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!