I am working on a project and i need to have the colume of 3 boxes but I keep getting errors when I try to compile.

Can anyone help and see what I am doing wrong? Here is what I have so far:

#include <iostream>
using std::cout;
using std::endl;
class CBox // Class definition at global scope
{
public:
double m_Length; // Length of a box in inches
double m_Width; // Width of a box in inches
double m_Height; // Height of a box in inches

// Function to calculate the volume of a box
double Volume()
{
return m_Length*m_Width*m_Height;
}


};
int main()

{
CBox box1; // Declare box1 of type CBox
CBox box2; // Declare box2 of type CBox
CBox box3; // Declare box3 of type CBox
double boxVolume = 0.0; // Stores the volume of a box
box1.m_Height = 18.0; // Define the values
box1.m_Length = 78.0; // of the members of
box1.m_Width = 24.0; // the object box1
box2.m_Height = box1.m_Height - 10; // Define box2
box2.m_Length = box1.m_Length/2.0; // members in
box2.m_Width = 0.25*box1.m_Length; // terms of box1
box3.m_Height = box1.m_Height -5;// Define box3
box3.m_Length = box1.m_Length /3.0;//members in
box3.m_Width = 0.30*box1.m_Length;//terms of box1

// Calculate volume of box1
boxVolume = box1.Volume(); // Calculate volume of box1
cout << endl
<< “Volume of box1 = “ << boxVolume;
cout << endl
<< “Volume of box2 = “
<< box2.Volume();
cout << endl
<< “Volume of box3 = “
<< box3.Volume();



cout << endl // Display the size of a box in memory
<< “A CBox object occupies “
<< sizeof box1 << “ bytes.”;
cout <<endl;
return 0;
}

Is the problem you are with your cout statements? is see you are using a instead of a " . If not please post what errors you are getting.

I am working on a project and i need to have the colume of 3 boxes but I keep getting errors when I try to compile.

Can anyone help and see what I am doing wrong?

Sure:
1) No formatting making the code difficult to follow.
2) No indication what the errors are so we don't know what to look for.
3) No indication where the errors are so we don't even know where to look.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.