forked from AfikPeretz/NumberWithUnits.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumberWithUnits.hpp
49 lines (41 loc) · 1.81 KB
/
NumberWithUnits.hpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <iostream>
#include <fstream>
#include <map>
using std::string;
using std::map;
using std::pair;
using std::ifstream;
using std::ostream;
using std::istream;
namespace ariel {
static map <string, map <string, double>> unitsType;
const static double epsilon = 0.00001;
class NumberWithUnits {
private:
pair <double, string> _unit;
public:
NumberWithUnits(double amount, const string &unit_type);
static void read_units(ifstream &file_name);
NumberWithUnits operator- () const;
NumberWithUnits operator+ (const NumberWithUnits &other_num) const;
NumberWithUnits operator+ () const;
NumberWithUnits & operator-- ();
NumberWithUnits & operator++ ();
NumberWithUnits operator-- (int);
NumberWithUnits operator++ (int);
NumberWithUnits operator- (const NumberWithUnits &other_num) const;
bool operator> (const NumberWithUnits &other_num) const;
bool operator< (const NumberWithUnits &other_num) const;
bool operator== (const NumberWithUnits &other_num) const;
bool operator<= (const NumberWithUnits &other_num) const;
bool operator>= (const NumberWithUnits &other_num) const;
bool operator!= (const NumberWithUnits &other_num) const;
NumberWithUnits& operator+= (const NumberWithUnits &num);
NumberWithUnits& operator-= (const NumberWithUnits &num);
NumberWithUnits operator* (double factor) const;
friend NumberWithUnits operator* (double factor, const NumberWithUnits &other_num);
friend ostream& operator<< (ostream& stream, const NumberWithUnits &num);
friend istream& operator>> (istream& stream, NumberWithUnits &num);
};
}