Something extra or messing in my code? (classes) help please

Chapter 6: Classes and data abstraction in c++
---------------------------------------...
Create a simple class that is used to represent a box. Each object of this class will store basic information about a box including its height, width, and length. Provide a constructor that initializes the class’ attributes and a set and get functions for each attribute. Provide a function called volume that calculates the volume of a box object.




my work.............


int getHeight();
int getWidth();
int getLength();
int volume();

private:
int height;
int width;
int length;

};

box::box(int h,int w, int l)
{
setHeight(h);
setWidth(w);
setLength(l);
}

void box::setHeight(int h)
{
if(h>0)
height=h;
else
height=0;
}
void box::setWidth(int w)
{
if(w>0)
width=w;
else
width=0;
}
void box::setLength(int l)
{
if(l>0)
length=l;
else
length=0;
}

int box::getHeight()

{ return height;

}
int box::getWidth()
{ return width;

}
int box::getLength()
{ return length;

}

int box::volume()
{ return length*width*height; }
Last edited on
help pleaaaaase
what kind of help do you need? I mean if it works it's good enough?
Topic archived. No new replies allowed.