I need help with an issue. I have been reminding myself how to use C++ and got back to inheritance. I have been using the tutorials on cplusplus.com for the code below
class Shape
{
protected:
int width, height;
public:
Shape(int w, int h) : width(w), height(h) { }
Shape()
{
width = 1;
height = 1;
}
void set_values (int w, int h)
{
width = w;
height = h;
}
};
class Rectangle : public Shape
{
public:
Rectangle()
{
width = 1;
height = 1;
}
Rectangle(int w, int h) : width(w), height(h) { }
~Rectangle() { }
int area ()
{
return (width * height);
}
};
However whenever I run a test, it always fails on the Rectangle's constructor. That seems to be where it always fails. Can anyone see where I have gone wrong?