68 lines · c
1#pragma once2 3/**4 * @brief A simple calculator class.5 *6 * Provides basic arithmetic operations.7 */8class Calculator {9public:10 /**11 * @brief Adds two integers.12 *13 * @param a First integer.14 * @param b Second integer.15 * @return int The sum of a and b.16 */17 int add(int a, int b);18 19 /**20 * @brief Subtracts the second integer from the first.21 *22 * @param a First integer.23 * @param b Second integer.24 * @return int The result of a - b.25 */26 int subtract(int a, int b);27 28 /**29 * @brief Multiplies two integers.30 *31 * @param a First integer.32 * @param b Second integer.33 * @return int The product of a and b.34 */35 int multiply(int a, int b);36 37 /**38 * @brief Divides the first integer by the second.39 *40 * @param a First integer.41 * @param b Second integer.42 * @return double The result of a / b.43 * @throw std::invalid_argument if b is zero.44 */45 double divide(int a, int b);46 47 /**48 * @brief Performs the mod operation on integers.49 *50 * @param a First integer.51 * @param b Second integer.52 * @return The result of a % b.53 */54 static int mod(int a, int b) {55 return a % b;56 }57 58 /**59 * @brief A static value.60 */61 static constexpr int static_val = 10;62 63 /**64 * @brief Holds a public value.65 */66 int public_val = -1;67};68