Task finished

This commit is contained in:
rhinemann 2024-10-14 21:19:17 +03:00
parent 4ad40a3b45
commit 3fdb5ddf40
5 changed files with 56 additions and 0 deletions

7
CMakeLists.txt Normal file
View File

@ -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)

13
src/Makefile Normal file
View File

@ -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

11
src/calculator.cpp Normal file
View File

@ -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);
}

11
src/calculator.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef CALCULATOR_H
#define CALCULATOR_H
class Calculator
{
public:
double Add (double, double);
double Sub (double, double);
};
#endif//CALCULATOR_H

14
src/main.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
#include <ostream>
#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;
}