-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdoubleintint.cpp
More file actions
72 lines (64 loc) · 1.9 KB
/
Copy pathdoubleintint.cpp
File metadata and controls
72 lines (64 loc) · 1.9 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "doubleintint.h"
#include "cconst.h"
/******************************************************************************************/
/**** Static member declarations ****/
/******************************************************************************************/
int DoubleIntIntClass :: sortby = CConst::NumericDouble;
/******************************************************************************************/
DoubleIntIntClass::DoubleIntIntClass(double d, int i0, int i1) {
dval = d;
ival0 = i0;
ival1 = i1;
}
DoubleIntIntClass::~DoubleIntIntClass() {
}
double DoubleIntIntClass::getDouble() {
return(dval);
}
int DoubleIntIntClass::getInt(int i) {
if (i==0) {
return(ival0);
} else {
return(ival1);
}
}
int DoubleIntIntClass::operator==(DoubleIntIntClass& val) {
if ((val.dval == dval) && (val.ival0 == ival0) && (val.ival1 == ival1)) {
return(1);
} else {
return(0);
}
}
int DoubleIntIntClass::operator>(DoubleIntIntClass& val) {
int retval;
switch(sortby) {
case CConst::NumericDouble:
if (dval > val.dval) {
retval = 1;
} else {
retval = 0;
}
break;
case CConst::NumericInt:
if (ival0 > val.ival0) {
retval = 1;
} else if (ival0 < val.ival0) {
retval = 0;
} else {
if (ival1 > val.ival1) {
retval = 1;
} else {
retval = 0;
}
}
break;
default:
retval = 0;
break;
}
return(retval);
}
std::ostream& operator<<(std::ostream& s, DoubleIntIntClass& val) {
s << "(" << val.dval << "," << val.ival0 << "," << val.ival1 << ")";
return(s);
}