Skip to content

About

My first C++ project: Calculator

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

C++ Console Calculator (Evolution & Refactor)

A practical C++ project showcasing the step-by-step evolution from a monolithic prototype to a clean, modular architecture.


Project Overview

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.

Key Technical Features (v2)

  • Modular Architecture: Functional decomposition separating user interface, input capture, and math operations (sumar, restar, multiplicar, dividir).
  • Pass-by-Reference (double &): Used in pedirnumeros() to modify variables directly across scopes without unnecessary memory copies.
  • Flow Control: Streamlined operation routing using a clean switch statement 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.

Tech Stack & Requirements

  • Language: C++ (C++11 or higher)
  • Compiler: MinGW / GCC / MSVC
  • Platform: Windows (Console)

How to Compile and Run

Clone the repository and compile using any standard C++ compiler:

# Compile Version 2
g++ -o calculator calculator_v2_modular.cpp

# Run executable
./calculator

About

My first C++ project: Calculator

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages