-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackerrank_Boxit.cpp
More file actions
46 lines (43 loc) · 914 Bytes
/
Copy pathhackerrank_Boxit.cpp
File metadata and controls
46 lines (43 loc) · 914 Bytes
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
class Box{
private:
int l, b, h;
public:
Box(){
l = 0;
b = 0;
h = 0;
}
Box(int length, int breadth, int height){
l = length;
b = breadth;
h = height;
}
Box(const Box& B){
l = B.l;
b = B.b;
h = B.h;
}
int getLenght(){
return l;
}
int getBreadth(){
return b;
}
int getHeight(){
return h;
}
long long CalculateVolume(){
return (long long)l*b*h;
}
friend bool operator < ( Box&A,Box& B){
if( (A.l < B.l) || ((A.b < B.b) && (A.l == B.l)) || ((A.h < B.h) && (A.l == B.l) && (A.b == B.b)) ){
return true;
}else{
return false;
}
};
friend ostream& operator<< (ostream& output, const Box& B){
output << B.l << " " << B.b << " " << B.h;
return output;
}
};