pgrm_013.cpp
Problem Statement
pgrm_013.cpp
in-line and non-inline functions
Source Code
cpp
#include<iostream>
using namespace std;
class cuboid {
private:
float length, breadth, height;
public:
cuboid() {length = breadth = height = 0;}
void getData();
void display();
//inline
float volume() {
return length * breadth * height;
}
//inline
float surfaceArea() {
return 2 * (length * breadth + breadth * height + height * length);
}
};
// non inline
void cuboid :: getData() {
cout << "Enter length, breadth and height: ";
cin >> length >> breadth >> height;
}
// non inline
void cuboid :: display() {
cout << "\nCuboid Details" << endl;
cout << "length: " << length << endl;
cout << "breadth: " << breadth << endl;
cout << "Height: " << height << endl;
cout << "Volume: " << volume() << endl;
cout << "Surface Area: " << surfaceArea() << endl;
}
int main() {
cuboid obj;
obj.getData();
obj.display();
return 0;
}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
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
● Author - Amit Dutta