Please use c code can you please make sure its right because
(Please use c++ code) can you please make sure it\'s right because the previous people who answered where wrong it didn\'t work.
Solution
//not sure, how other people got it wrong ;)
//do comment, if it still doesn\'t matches your needs
#include <iostream>
#include <cassert>
using namespace std;
class rectangle{
double width;
double height;
public:
rectangle( double wdth, double hgt ){
width = wdth;
height = hgt;
}
double area(){
return width*height;
}
bool isSquare(){
return ( width == height );
}
};
int main(){
rectangle foo(3,4);
rectangle bar(5,5);
cout << \"The area of rectangle foo is: \" << foo.area() << endl;
cout << \"The area of rectangle bar is: \" << bar.area() << endl;
assert( foo.isSquare() == false );
assert( bar.isSquare() == true );
return 0;
}
