1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
diff --git a/calculator.cpp b/calculator.cpp
new file mode 100644
index 0000000..abc1234
--- /dev/null
+++ b/calculator.cpp
@@ -0,0 +1,28 @@
+#include "calculator.h"
+
+double Calculator::add(double a, double b) {
+ return a + b;
+}
+
+double Calculator::divide(double a, double b) {
+ if (b == 0) {
+ throw std::invalid_argument("Division by zero");
+ }
+ return a / b;
+}
+
+std::vector<double> Calculator::processNumbers(const std::vector<double>& numbers, std::function<double(double)> processor) {
+ std::vector<double> result;
+
+ for (const auto& num : numbers) {
+ result.push_back(processor(num));
+ }
+
+ return result;
+}
|