-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathaddvolumfrendfunc.cpp
52 lines (49 loc) · 963 Bytes
/
addvolumfrendfunc.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
#include <iostream>
#include <String>
using namespace std;
class Cuboid;
class Sphere
{
private:
int radius;
double volume;
public:
void Acceptdata()
{
cout << "Enter the radius:";
cin >> radius;
}
void CalculateVolume()
{
volume = 4 / 3.0 * 3.14 * radius * radius * radius;
}
void Display()
{
cout << "The volume of Sphere is :" << volume << endl;
}
friend void AddVolume(Sphere sph, Cuboid cbd);
};
class Cuboid
{
private:
int length, breadth, height;
double volume;
public:
void AcceptData()
{
cout << "Enter the length:";
cin >> length;
cout << "Enter the breadth:";
cin >> breadth;
cout << "Enter the height:";
cin >> height;
}
void CalculateVolume()
{
volume = length * breadth * height;
}
void Display()
{
cout << "The volume of Sphere is:" << volume << endl;
}
};