There are a number of errors with just this main.cpp namely:
line 11, Rectangle r is an error because the Rectangle class does not have a default constructor
line 12,
in >> r is an error because you have not overloaded the
>> operator
for Rectangle
line 13, the error message you got is saying that Rectangle class did not overload the subscript operator, so you cannot do r[0] or r[1]
line 14,
cout << r;
this is an error because you have not overloaded the
<< operator
for Rectangle
line 16,
if ( r1 == r2 )
, another error because you did not overload the
== operator
for Rectangle
Easy fix for line 11, create a default constructor in the Rectangle class
Easy fix for line 13/14, use
Rectangle::getWidth, Rectangle::getHeight
Easy fix for line 12, in the Rectangle.h file:
1 2 3 4
|
friend istream& operator >> (istream &iss, Rectangle& r) {
iss >> r.height >> r.width;
return iss;
}
|
For line 16, use the example I've just shown above to overload the == operator (return type is bool), or simply just use
Rectangle::getWidth, Rectangle::getHeight