This repository contains all of my C++ modules from the 42 curriculum, designed to introduce students to Object-Oriented Programming and C++ fundamentals through a series of increasingly complex exercises.
"From procedural to object-oriented: a journey through the core of C++."
Each module focuses on specific C++ concepts, gradually building a comprehensive understanding of the language and its features.
Focus: Basic C++ syntax and object-oriented programming fundamentals.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Megaphone | Convert input strings to uppercase | Command-line arguments, string manipulation, basic I/O | 
| ex01: Contact Management | Simple phonebook application | Classes, member functions, arrays, user input handling | 
| ex02: Job Management | Restore account data from a corrupted file | File parsing, class implementation | 
| ex03: Inventory Management | Simulate an inventory system with items | Class design, constructors/destructors, static members | 
| ex04: Sed-like Program | Implement a simplified version of the Unix sed command | File manipulation, string replacement, command-line parsing | 
| ex05: Harl 2.0 | Create a class that filters messages based on severity levels | Function pointers, switch-case statements, logging mechanisms | 
| ex06: Filtered Logger | Extend the logger to filter messages by severity | Advanced control flow, function pointers, modular design | 
Focus: Dynamic memory management, references, and file streams.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: BraiiiiiiinnnzzzZ | Implement a Zombie class with dynamic allocation | Dynamic memory allocation (new/delete), constructors/destructors | 
| ex01: Moar brainz! | Create a function that spawns multiple zombies | Arrays, dynamic allocation, loops | 
| ex02: HI THIS IS BRAIN | Demonstrate pointers and references | Pointer vs reference semantics | 
| ex03: Weapon & Human | Implement Weapon and Human classes with references | References, class interactions, member functions | 
| ex04: File Replacer | Replace strings in a file | File I/O, string manipulation, error checking | 
| ex05: Karen Filter | Filter messages based on severity levels | Function pointers, control flow, logging | 
| ex06: Switch Logger | Implement a logger using switch-case statements | Switch statements, function pointers, modular design | 
Focus: Operator overloading and canonical class form.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Fixed Point Class | Create a class to represent fixed-point numbers | Class design, constructors, member functions | 
| ex01: Enhanced Fixed Class | Add constructors and functions to the fixed-point class | Constructor overloading, member function implementation | 
| ex02: Operator Overloading | Implement arithmetic and comparison operators | Operator overloading, const correctness | 
| ex03: Point in Triangle | Determine if a point lies within a triangle | Geometric calculations, function implementation | 
Focus: Class inheritance and access control.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: ClapTrap | Implement a base ClapTrap class | Class design, member functions | 
| ex01: ScavTrap | Create a ScavTrap class derived from ClapTrap | Inheritance, constructors in derived classes | 
| ex02: FragTrap | Add another derived class with different behavior | Multiple inheritance, virtual functions | 
| ex03: DiamondTrap | Handle the diamond problem with multiple inheritance | Virtual inheritance, constructor chaining | 
Focus: Subtype polymorphism, abstract classes, and interfaces.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Polymorphism | Implement base Animal class with derived Cat and Dog classes | Inheritance, virtual functions, polymorphism | 
| ex01: Deep Copies | Manage deep copies in derived classes | Copy constructors, assignment operators, dynamic memory management | 
| ex02: Abstract Classes | Make Animal an abstract class | Pure virtual functions, interface design | 
| ex03: Interfaces & Multiple Inheritance | Implement Character and AMateria classes with types like Ice and Cure | Interfaces, multiple inheritance, polymorphic behavior | 
Focus: Exception handling and class-based exceptions.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Introduction to Exceptions | Implement basic exception handling | Try-catch blocks, standard exceptions | 
| ex01: Custom Exceptions | Create custom exception classes | Exception hierarchies, inheritance in exceptions | 
| ex02: Form Bureaucracy | Implement a form processing system with validation | Complex exception handling, form validation | 
| ex03: Bureaucracy Expansion | Extend the bureaucratic system with more forms | Polymorphism with exceptions, system design | 
Focus: Understanding and applying different C++ casting operators and runtime type identification.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Scalar Conversion | Convert input strings to various scalar types using static_cast | Type casting, input validation, exception handling | 
| ex01: Serialization | Serialize and deserialize data using reinterpret_cast | Pointer manipulation, memory representation, serialization techniques | 
| ex02: Runtime Type Identification | Identify derived classes (A, B, or C) from a base class using dynamic_cast | RTTI, polymorphism, safe downcasting | 
Focus: Introduction to function and class templates for generic programming.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Function Templates | Implement generic swap function and other utilities | Function templates, generic programming | 
| ex01: Class Templates | Create a templated Array class with bounds checking | Class templates, exception handling, operator overloading | 
| ex02: Template Specialization | Implement template specialization for specific data types | Template specialization, advanced template usage | 
Focus: Utilizing STL containers and algorithms with templates.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Easy Find | Implement a function to find a value in a container | STL algorithms, iterators, exception handling | 
| ex01: Span | Create a Span class to find shortest and longest spans in a set of numbers | STL containers (std::vector), algorithm optimization | 
| ex02: MutantStack | Implement a stack that supports iteration | Container adapters, inheritance, iterator implementation | 
Focus: Deepening understanding of STL containers and their applications.
| Exercise | Description | Skills | 
|---|---|---|
| ex00: Bitcoin Exchange | Implement a Bitcoin price calculator based on a database | STL containers (map), file parsing, data validation | 
| ex01: RPN Calculator | Create a Reverse Polish Notation calculator | STL containers (stack), algorithm implementation | 
| ex02: PmergeMe | Implement a merge-insert sort algorithm for sequences | STL containers, sorting algorithms, performance optimization | 
- Master the basics of C++ syntax and semantics
 - Understand object-oriented programming principles
 - Implement class hierarchies with inheritance
 - Use polymorphism to create flexible and extensible code
 - Handle errors and exceptions properly
 - Work with memory allocation and references
 - Utilize operator overloading for intuitive interfaces
 - Apply generic programming through templates
 - Leverage the Standard Template Library (STL)
 - Develop good programming practices and code organization
 
- OOP Fundamentals: Classes, objects, encapsulation, inheritance, polymorphism
 - Memory Management: Stack vs heap, new/delete operators, memory leaks prevention
 - C++ Specifics: References, const correctness, operator overloading, canonical form
 - Templates: Function templates, class templates, template specialization
 - STL: Containers (vector, list, map, stack), iterators, algorithms
 - Error Handling: Exceptions, custom exception classes, RAII principle
 - Type Safety: Type casting, RTTI, compile-time vs runtime checks
 - Design Patterns: Basic implementation of common patterns
 
- Translating concepts into practical code
 - Designing maintainable and reusable class hierarchies
 - Creating robust applications with proper error handling
 - Implementing generic solutions with templates
 - Optimizing code performance and memory usage
 - Following coding standards and best practices
 
Each module can be built using the provided Makefile:
# Navigate to the module directory
cd CPP00/ex01
# Compile
make
# Run (example for phonebook)
./phonebook| Metric | Value | 
|---|---|
| Modules | 10 (CPP00-CPP09) | 
| Exercises | 45+ | 
| Concepts Covered | 20+ | 
| C++ Version | C++98 | 
