-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber.h
More file actions
57 lines (45 loc) · 1.54 KB
/
Number.h
File metadata and controls
57 lines (45 loc) · 1.54 KB
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
50
51
52
53
54
55
56
57
#ifndef NUMBER_H
#define NUMBER_H
#include <string>
class Number
{
public:
// (Oscar) Constructors/Deconstructor
Number(); // Default Constructor: Initialized to 0
Number(std::string s); // String Constructor "xxx.xxx"
Number(const char* s);
Number(const Number& n); // Copy Constructor
Number(Number&& n); // Move Constructor
~Number();
// (Oscar) Arithmetic Operators
Number operator+(const Number& n) const;
Number operator-(const Number& n) const;
Number operator*(const Number& n) const;
Number operator/(const Number& n) const;
// (Oscar) Comparison Operators
bool operator<(const Number& n) const;
bool operator>(const Number& n) const;
bool operator==(const Number& n) const;
bool operator!=(const Number& n) const;
bool operator>=(const Number& n) const;
bool operator<=(const Number& n) const;
// (Oscar) Assignment Operators
Number& operator=(std::string s);
Number& operator=(const char* s);
Number& operator=(Number&& n);
Number& operator=(const Number& n);
Number& operator+=(const Number& n);
Number& operator-=(const Number& n);
Number& operator*=(const Number& n);
Number& operator/=(const Number& n);
// (Oscar) Input Operator
friend std::istream& operator>>(std::istream& is, Number& n);
// (Oscar) Output Operator
friend std::ostream& operator<<(std::ostream& os, const Number& n);
// (Sam) sqrt
friend Number sqrt(const Number& n);
private:
struct Impl;
Impl* pimpl;
};
#endif // NUMBER_H