-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiscInt.cpp
37 lines (32 loc) · 1.11 KB
/
DiscInt.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
/*
Description: This file holds the implementation code for the DiscInt class declared in DiscInt.h file . For details pls. see the comments in DiscInt.h file
Precondition: DiscInt.h is defined
Postcondition: methods defined in DiscInt.h have its implementation code written here.
*/
#include <iostream>
#include <cstdlib>
#include "DiscInt.h" //header file is included
using namespace std;
int DiscInt::get_disc() const //returns the value in disc variable
{
return disc_int;
}
std::ostream& operator <<(std::ostream& out,const DiscInt& value) //operator overloding function to print the value in disc
{
out << value.get_disc() << endl;
return out;
}
bool operator == (const DiscInt& d1, const DiscInt& d2) //operator overloding function to return boolean value based on the comparision of 2 disc
{
if(d1.get_disc()==d2.get_disc())
return true;
else
return false;
}
bool operator <(const DiscInt& d1, const DiscInt& d2) // operator overloading function to compare 2 objects of DiscInt class and return boolean value
{
if(d1.get_disc() < d2.get_disc())
return true;
else
return false;
}