MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / Box

Class Box

Examples/NoModules/Chapter 12/Ex12_01/Ex12_01.cpp:5–27  ·  view source on GitHub ↗

Class to represent a box

Source from the content-addressed store, hash-verified

3
4// Class to represent a box
5class Box
6{
7public:
8 // Constructor
9 Box(double length, double width, double height)
10 {
11 std::cout << "Box constructor called." << std::endl;
12 m_length = length;
13 m_width = width;
14 m_height = height;
15 }
16
17 // Function to calculate the volume of a box
18 double volume()
19 {
20 return m_length * m_width * m_height;
21 }
22
23private:
24 double m_length {1.0};
25 double m_width {1.0};
26 double m_height {1.0};
27};
28
29int main()
30{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected