I am trying to write code which will display the volume of three boxes. I have my code but am having problems getting it to compile. Any help would be greatly appreciated. Here is my code:
//Assignment Programming Using Structures and Classes
// Creating and using boxes
#include <iostream>
using std::cout;
using std::endl;
int volume(int& m_Length, int& m_Width, int& m_Height); //Function prototype
class CBox // Class definition at global scope
{
public:
int m_Length; // Length of a box in inches
int m_Width; // Width of a box in inches
int m_Height; // Height of a box in inches
}
int main(void)
{
int volume1;
int volume2;
int volume3;
CBox box1; // Declare box1 of type CBox
CBox box2; // Declare box2 of type CBox
CBox box3; // Declare box3 of type CBox
int box1 m_Height = 18.0; // Define the values
int box1 m_Length = 78.0; // of the members of
int box1 m_Width = 24.0; // the object box1
int volume1 = volume;
int box2 m_Height = 12.0;
int box2 m_Length = 37.0;
int box2 m_Width = 42.0;
int volume2 = volume;
int box3 m_Height = 15.9;
int box3 m_Length = 28.0;
int box3 m_Width = 58.2;
int volume3 = volume;
int result = volume(m_Length, m_Width, m_Height);
cout << endl
<<"volume(int m_Length, int m_Width,int m_Height) = "<< volume1(int m_Length), int m_Width, int m_Height)
<<endl
<< "The volume of box 1 is "<< volume1;
cout<<endl
<<"volume(int m_Length, int m_Width,int m_Height) = "<< volume2(int m_Length, int m_Width, int m_Height)
<<endl
<< "The volume of box 2 is "<< volume2;
cout<<endl
<<"volume(int m_Length, int m_Width,int m_Height) = "<< volume3(int m_Length, int m_Width, int m_Height)
<<endl
<< "The volume of box 3 is "<< volume3;
cout<<endl;
;
return 0;
}
// Function to calculate volume
int volume(int& m_Length, int& m_Width,int& m_Height)
{
int volume = m_Length*m_Width*m_Height;
return volume;
}