diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7a1b4d7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10) + +set(CMAKE_CXX_STANDARD 20) + +project(Task_2) + +add_executable(Task_2 src/main.cpp src/calculator.cpp) diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..e8f2f55 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,13 @@ +all: main + +main: main.o calculator.o + g++ main.o calculator.o -o main + +main.o: + g++ -c main.cpp + +calculator.o: + g++ -c calculator.cpp + +clean: + rm -rf *.o main diff --git a/src/calculator.cpp b/src/calculator.cpp new file mode 100644 index 0000000..516e4f1 --- /dev/null +++ b/src/calculator.cpp @@ -0,0 +1,11 @@ +#include "calculator.h" + +double Calculator::Add (double a, double b) +{ + return a + b; +} + +double Calculator::Sub (double a, double b) +{ + return Add (a, -b); +} diff --git a/src/calculator.h b/src/calculator.h new file mode 100644 index 0000000..6fbe608 --- /dev/null +++ b/src/calculator.h @@ -0,0 +1,11 @@ +#ifndef CALCULATOR_H +#define CALCULATOR_H + +class Calculator +{ + public: + double Add (double, double); + double Sub (double, double); +}; + +#endif//CALCULATOR_H diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..18fca31 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,14 @@ +#include +#include +#include "calculator.h" + +int main() { + Calculator calculator; + + std::cout << "100.5 + 34.76 = " + << calculator.Add(100.5, 34.76) << "\n" + << "235.765 - 24.767 = " << calculator.Sub(235.765, 24.767) + << std::endl; + + return 0; +} \ No newline at end of file