I am trying to Implement the class Rectangle which consists of two Points representing opposing corners of the rectangle. The Point struct has already been declared in the header file. I do not know how to use the x,y in the struct class in the Rectangle Class.
The is the .h file:
struct Point {
double x, y;
};
// Define your class below this line
class Rectangle
{
public:
Rectangle(double p.x, double p.y, double w, double h);
double getArea() const;
double getWidth() const;
double getHeight() const;
double getX() const;
double getY() const;
void setLocation(double x, double y);
void setHeight(double w, double h);
private:
Point p;
double width;
double height;
};
In the .cpp I initialize like:
Rectangle::Rectangle(double p.x, double p.y, double w, double h)
:(p.x),(p.y), width(w), height(h)
{
}