/*
 * C++ Comments Sample
 * This file demonstrates various comment styles in C++
 */

#include <iostream>
#include <vector>
#include <string>

// Single-line comment: Include standard namespace
using namespace std;

/**
 * Class representing a simple calculator
 *
 * This class provides basic arithmetic operations
 * and maintains a history of calculations.
 */
class Calculator {
private:
    // Private member variables
    vector<double> history; // Calculation history
    int precision; // Decimal precision for output

public:
    /**
     * Constructor for Calculator
     * @param prec - Number of decimal places (default: 2)
     */
    Calculator(int prec = 2) : precision(prec) {
        // Initialize with empty history
    }

    /* Multi-line comment style
       for method documentation */
    double add(double a, double b) {
        double result = a + b;
        // Add to history
        history.push_back(result);
        return result;
    }

    // Single-line comment for subtract method
    double subtract(double a, double b) {
        return a - b; // Perform subtraction
    }

    /**
     * Multiply two numbers
     * @param a First number
     * @param b Second number
     * @return Product of a and b
     */
    double multiply(double a, double b) {
        /* Calculate and return product */
        return a * b;
    }

    /* Division with error checking
       Returns 0 if divisor is zero */
    double divide(double a, double b) {
        if (b == 0) {
            // Handle division by zero
            cout << "Error: Division by zero" << endl;
            return 0;
        }
        return a / b;
    }

    // Display calculation history
    void displayHistory() {
        /* Print all calculations */
        cout << "Calculation History:" << endl;
        for (double value : history) {
            cout << "= " << value << endl;
        }
    }
};

/* Main function - entry point of the program
   Demonstrates the Calculator class usage */
int main() {
    // Create calculator instance
    Calculator calc(4);

    // Perform calculations
    double sum = calc.add(10.5, 20.3);
    double diff = calc.subtract(50.0, 25.5);
    double product = calc.multiply(7.0, 6.0);
    double quotient = calc.divide(100.0, 4.0);

    // Display results with comments
    cout << "Results:" << endl;
    cout << "Sum: " << sum << endl;
    cout << "Difference: " << diff << endl;
    /* These results demonstrate
       the calculator functionality */
    cout << "Product: " << product << endl;
    cout << "Quotient: " << quotient << endl;

    // Show history
    calc.displayHistory();

    // Single-line comment at end
    return 0;
}

/*
 * End of C++ sample file
 * This concludes the demonstration of C++ comments
 * including both single-line (//) and multi-line (/* * /) styles
 */
