File: git_diff_cpp_functions.txt

package info (click to toggle)
diff-cover 10.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,256 kB
  • sloc: python: 6,452; xml: 218; cpp: 18; sh: 12; makefile: 10
file content (28 lines) | stat: -rw-r--r-- 679 bytes parent folder | download
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;
+}