Medium
CPP-003cppBuild a Fraction Class (OOP)
Problem
Design a `Fraction` class with a constructor, `+`, and `operator<<`. Auto-simplify to lowest terms using GCD.
Input
Not applicable — demonstrate with fixed test cases inside main.
Output
Simplified fractions as `p/q`.
Constraints
Numerator + denominator ≤ 10^9
Sample input
(hardcoded: 1/2 + 1/3)
Sample output
5/6
Explanation
1/2 + 1/3 = 3/6 + 2/6 = 5/6; already simplified.
oopclassesoperatorsmath@Microsoft@Oracle
Visible test cases
in: (1/2 + 1/3)
out: 5/6
Your solution — run it, use AI if stuck
cpp
