Task finished
This commit is contained in:
parent
4ad40a3b45
commit
3fdb5ddf40
|
@ -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)
|
|
@ -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
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef CALCULATOR_H
|
||||
#define CALCULATOR_H
|
||||
|
||||
class Calculator
|
||||
{
|
||||
public:
|
||||
double Add (double, double);
|
||||
double Sub (double, double);
|
||||
};
|
||||
|
||||
#endif//CALCULATOR_H
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue