My 42 C++ modules repository, from Module_00 to Module_09.
C++98, OOP, inheritance, polymorphism, templates, STL, 42 curriculum
CPP_42 is a repository developed as part of the 42 curriculum.
This repository groups the exercises available under Module_00 to Module_09. Each exercise is an independent mini-project with its own Makefile, its own executable, and its own include/ and src/ folders.
This repository focuses on:
- learning the C++98 toolchain and compilation rules
- building classes and object-oriented abstractions
- practicing inheritance, polymorphism, exceptions, and templates
- working with STL containers and algorithmic exercises
- 10 modules organized from
Module_00toModule_09 - 34 exercise folders (
ex00toex05depending on the module) - a dedicated
Makefilein every exercise directory - a progression from simple CLI programs to generic and STL-based exercises
- helper targets such as
run,help,valgrind, and sometimesleaksin many Makefiles - no root
Makefile: each exercise must be compiled independently
Through this repository, I worked on the following concepts:
- classes, encapsulation, and member functions
- pointers, references, and dynamic allocation
- operator overloading and canonical class structure
- inheritance, polymorphism, abstract classes, and interfaces
- exceptions, conversions, serialization, and type identification
- templates, iterators, containers, and STL-oriented problem solving
Clone the repository and compile the exercise you want to work on:
git clone git@github.com:Middle-555/CPP_42.git
cd CPP_42/Module_00/ex00
makeAvailable Makefile rules in every exercise:
make
make clean
make fclean
make reAdditional notes:
- all 34 exercise Makefiles compile with
-Wall -Wextra -Werror -std=c++98 - many exercises also provide
make run,make help, andmake valgrind - several later exercises also provide
make leakson macOS
Run the executable from the corresponding exercise directory.
cd Module_00/ex00 && ./Megaphone "hello" "42"
cd Module_00/ex01 && ./Phonebook
cd Module_09/ex02 && ./PmergeMe 3 5 9 7 4Usage notes:
- some programs are interactive, such as
Phonebook - some programs expect arguments or input files, depending on the exercise
- executable names change from one exercise to another, so check the local
Makefile
.
├── Module_00/
│ ├── ex00/
│ └── ex01/
├── Module_01/
│ ├── ex00/
│ ├── ex01/
│ ├── ex02/
│ ├── ex03/
│ ├── ex04/
│ └── ex05/
├── Module_02/
│ ├── ex00/
│ ├── ex01/
│ └── ex02/
├── Module_03/
│ ├── ex00/
│ ├── ex01/
│ └── ex02/
├── Module_04/
│ ├── ex00/
│ ├── ex01/
│ ├── ex02/
│ └── ex03/
├── Module_05/
│ ├── ex00/
│ ├── ex01/
│ ├── ex02/
│ └── ex03/
├── Module_06/
│ ├── ex00/
│ ├── ex01/
│ └── ex02/
├── Module_07/
│ ├── ex00/
│ ├── ex01/
│ └── ex02/
├── Module_08/
│ ├── ex00/
│ ├── ex01/
│ └── ex02/
├── Module_09/
│ ├── ex00/
│ ├── ex01/
│ └── ex02/
├── template.md
└── README.md
Module_00/: first CLI exercises withMegaphoneandPhonebookModule_01/: memory, references, small utility classes, file replacement, and dispatchingModule_02/:Fixedclass exercises and operator-related workModule_03/: inheritance through theClapTrap,ScavTrap, andFragTraphierarchyModule_04/: polymorphism, abstract classes, deep copy work, and the Materia systemModule_05/: exception-oriented exercises withBureaucrat, forms, and anInternModule_06/: scalar conversion, serialization, and runtime type identificationModule_07/: generic programming with templates,iter, and a templatedArrayModule_08/: STL helper exercises such asEasyFind,Span, andMutantStackModule_09/: practical STL exercises withBitcoinExchange,RPN, andPmergeMe
This repository follows constraints that are visible in the current project files:
- written in C++
- compiled in C++98 mode
- one independent
Makefileper exercise - strict warning flags enabled:
-Wall -Wextra -Werror - organized as a set of small, focused exercises rather than one single application
Each exercise can be checked locally with the same general workflow:
- compile the target exercise with
make - run the executable manually with the expected arguments
- use
make valgrindwhen the target exists - use
make leakson macOS when the target exists - compare the observed output with the expected exercise behavior
cd Module_00/ex00 && make && ./Megaphone "hello" "42"
cd Module_00/ex01 && make && ./Phonebook
cd Module_09/ex02 && make && ./PmergeMe 3 5 9 7 4cd Module_09/ex02 && make valgrindTesting note:
- there is no single root test command for the whole repository because every exercise is independent
This repository helped me improve in the following areas:
- structuring small C++ projects with headers, sources, and Makefiles
- moving from basic classes to more advanced OOP patterns
- reasoning about object lifetime, copying, and resource ownership
- using templates and STL containers to solve generic problems
Although the repository already provides a clear learning path, several improvements could be considered:
- add a root script to build all exercises automatically
- add a short subject summary for each module
- add CI to compile the exercises automatically on push
- add dedicated regression tests for the most complex exercises
Middle
42 student