-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx 7B...Friend Class.cpp
41 lines (41 loc) · 1.27 KB
/
Ex 7B...Friend Class.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
#include<iostream>
#include<conio.h>
using namespace std;
class student
{
char name[20];
int mark1,mark2,mark3;
friend class friendclass;
public:
void get_data()
{
cout<<"\nEnter name:";
cin>>name;
cout<<"\nEnter 3 marks:";
cin>>mark1>>mark2>>mark3;
}
void display(int a)
{
cout<<"\nOutput\n ";
cout<<"=============\n";
cout<<"\nName ="<<name;
cout<<"\nAverage ="<<a;
}
};
class friendclass
{
public:
void mark_avg(student &stud)
{
int avg=(stud.mark1+stud.mark2+stud.mark3)/3;
stud.display(avg);
}
};
int main()
{
student s;
s.get_data();
friendclass obj;
obj.mark_avg(s);
getch();
}