I'm quite new to C++, and I have a problem with my class definition. This is most likely a pretty basic operation, but I can't find any relevant resources online, as I'm not quite sure what to search for.
The title says it all. I have a header file looking like the following:
class Rectangle{
public:
int Width();
int Height();
int Area();
void Resize();
private:
int width;
int height;
}
And then I have the following .cpp file.
int Rectangle::Width()
{
//return the width
}
int Rectangle::Height()
{
//return the height
}
int Rectangle::Area()
{
//return the area
}
void Rectangle::Resize()
{
//resize the rectangle
}
As you can see, I have commented the operations that I wish to do, but I am not quite sure how to access the variables int width and int height from the header file.
;after your class definition.;after my definition. Just didn't copy paste. I have included the header file, I simply don't know how to access the variables.unsigned intfor height and width. Regularintcan go negative. In my life experience, I haven't come across negative heights or widths, but I'm open to seeing a rectangle with negative width or height. Same with area.