-
Notifications
You must be signed in to change notification settings - Fork 0
/
FriendFunctionDisplay.cpp
66 lines (62 loc) · 1.3 KB
/
FriendFunctionDisplay.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
60
61
62
63
64
65
66
// Using display function as Friend Function
#include<iostream>
using namespace std;
class Account
{
private:
char Name[30];
float Balance;
int Age;
public:
Account();
Account(char name, float balance, int age)
{
Name = name;
Balance = balance;
Age = age;
}
Account(Account obj)
{
Name = obj.Name;
Balance = obj.Balance;
Age = obj.Age;
}
friend void display(Account obj);
~Account()
{
}
};
Account::Account()
{
cout<<"Enter the Name: ";
cin>>Name;
cout<<"Enter the Balance: ";
cin>>Balance;
cout<<"Enter the Age: ";
cin>>Age;
}
void display(Account obj)
{
cout<<"\t\tName: "<<obj.Name<<endl;
cout<<"\t\tBalance: "<<obj.Balance<<endl;
cout<<"\t\tAge: "<<obj.Age<<endl;
cout<<"****************************"<<endl;
}
int main()
{
char name[30];
float balance;
int age;
cout<<"Enter your name: ";
cin>>name;
cout<<"Enter your balance: ";
cin>>balance;
cout<<"Enter your Age: ";
cin>>age;
Account memb1, memb2(name, balance, age), memb3(memb2);
cout<<"**********************"<<endl;
display(memb1);
display(memb2);
display(memb3);
return 0;
}