-
Notifications
You must be signed in to change notification settings - Fork 1
/
q8.cpp
49 lines (47 loc) · 805 Bytes
/
q8.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
#include <iostream>
using namespace std;
class company
{
int salary;
int modules;
public:
void read()
{
cout<<"enter salary:";
cin>>salary;
cout<<"enter no. of modules:";
cin>>modules;
}
void print()
{
cout<<"Salary is: "<<salary<<endl;
cout<<"no. of modules are: "<<modules<<endl;
}
company operator +(company c)
{
company obj;
obj.salary = salary + c.salary;
obj.modules = modules + c.modules;
return obj;
}
company operator -(company c)
{
company obj;
obj.salary = salary - c.salary;
obj.modules = modules - c.modules;
return obj;
}
};
int main()
{
company obj1,obj2,add,sub;
obj1.read();
obj2.read();
add = obj1 + obj2;
cout<<"After addition:"<<endl;
add.print();
sub = obj1 - obj2;
cout<<endl<<"After subtraction:"<<endl;
sub.print();
return 0;
}