-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPRA_15
44 lines (39 loc) · 776 Bytes
/
PRA_15
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
/* A program to demonstrate use of friend function */
#include<iostream>
using namespace std;
class Area //defining class
{
int r;// data member
public:
friend float cirArea(Area);// friend function declaration
void getRadius() //method to fetch radius
{
cout << "Enter Radius : ";
cin >> r;
}
void putArea(float a)//method to display area
{
cout << "Circle area = "<< a;
}
};
float cirArea(Area a) // defining friend function to calculate area
{
return (3.14)*(a.r)*(a.r);
}
int main()
{
Area c;
float A;
c.getRadius();
A=cirArea(c);
c.putArea(A);
return 0;
}
/*
Output :
Enter Radius : 8
Circle area = 200.96
--------------------------------
Process exited after 5.263 seconds with return value 0
Press any key to continue . . .
/*