A practical C++ project showcasing the step-by-step evolution from a monolithic prototype to a clean, modular architecture.
This repository demonstrates fundamental software engineering principles in C++, focusing on refactoring, memory management, and code readability.
- Version 1 (
calculator_v1_monolithic.cpp): Initial prototype managing input flow, multiple menu loops, and arithmetic operations within a single monolithic execution block. - Version 2 (
calculator_v2_modular.cpp): Refactored architecture decomposing tasks into dedicated functions, implementing memory-efficient references, and handling edge cases.
- Modular Architecture: Functional decomposition separating user interface, input capture, and math operations (
sumar,restar,multiplicar,dividir). - Pass-by-Reference (
double &): Used inpedirnumeros()to modify variables directly across scopes without unnecessary memory copies. - Flow Control: Streamlined operation routing using a clean
switchstatement instead of deeply nested conditional blocks. - Error Handling: Explicit division-by-zero validation to prevent runtime crashes.
- Console Localization: Configured Windows UTF-8 console output (
SetConsoleCP/SetConsoleOutputCP) for proper character and accent rendering.
- Language: C++ (C++11 or higher)
- Compiler: MinGW / GCC / MSVC
- Platform: Windows (Console)
Clone the repository and compile using any standard C++ compiler:
# Compile Version 2
g++ -o calculator calculator_v2_modular.cpp
# Run executable
./calculator