-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSalary.cpp
59 lines (59 loc) · 1.05 KB
/
Salary.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
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class wife;
class husband
{
double a;
char h_name[10];
public:
husband(long int,char[]);
friend void salary(husband,class wife);
};
class wife
{
double b;
char w_name[10];
public:
wife(long int,char[]);
friend void salary(husband, wife);
};
husband::husband(long int x,char y[])
{
a=x;
strcpy(h_name,y);
}
wife::wife(long int c,char d[])
{
b=c;
strcpy(w_name,d);
}
void salary(husband h,wife w)
{
double salary;
salary=h.a+w.b;
cout<<"The name of the husband is : "<<h.h_name<<endl;
cout<<"The salary of the husband is : "<<h.a<<endl;
cout<<"The name of the wife is : "<<w.w_name<<endl;
cout<<"The salary of the wife is : "<<w.b<<endl;
cout<<"The total salary : "<<salary<<endl;
}
void main()
{
clrscr();
double a,b;
char x[10],y[10];
cout<<endl<<"Enter the name of husband : "<<endl;
cin>>x;
cout<<"Enter the salary of husband : "<<endl;
cin>>a;
cout<<"Enter the name of wife : "<<endl;
cin>>y;
cout<<"Enter the salary of wife : "<<endl;
cin>>b;
husband h(a,x);
wife w(b,y);
salary(h,w);
getch();
}