Complex Numbers in C++
A from-scratch C++ class implementing complex number arithmetic, including operator overloading for standard mathematical operations.
Project Overview
A from-scratch implementation of a complex number class in C++, covering construction, copy/move assignment, equality, and arithmetic — addition, subtraction, and multiplication — through operator overloading.
Technical Details
- Implemented as a standalone
ComplexNumberclass (complex_number.hpp/complex_number.cpp) with no external dependencies. - Overloads
+,-,*,==, and stream insertion/extraction (<</>>), plus ato_string()helper for formatted output. - Every constructor, destructor, and assignment prints a trace line, making it a handy way to observe C++ object lifetime while stepping through
main.cpp. - Compiled directly with g++:
g++ -o build/demo main.cpp complex_number.hpp complex_number.cpp.