-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxIt.cpp
73 lines (60 loc) · 1.44 KB
/
BoxIt.cpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Box{
private :
int l=0,b=0,h=0;
public:
// Constructors
Box(){
l = 0;
b = 0;
h = 0;
}
Box(int l1,int b1, int h1){
//
l = l1;
b = b1;
h = h1;
}
// Copy Constructor
Box(const Box &B){
l = B.l;
b = B.b;
h = B.h;
}
int getLength(){
return Box::l;
}
int getBreadth(){
return Box::b;
}
int getHeight(){
return Box::h;
}
long long CalculateVolume(){
long long volume = l;
volume *= b;
volume *= h;
return volume;
}
bool operator < (Box& B){
if(l < B.l) {
return true;
}
else if((b < B.b) && (l == B.l)){
return true;
}
else if((h < B.h)&&(b == B.b)&&(l == B.l)){
return true;
}
else{
return false;
}
}
void print(ostream &ostr) {
ostr << l << "\t" << b<< "\t" << h;
}
};
//template <class T>
std::ostream & operator<<(std::ostream& out, Box& B){
B.print(out);
return out;
}