22 lines
534 B
C++

#ifndef EXAMPLE14_RECTANGLE_H
#define EXAMPLE14_RECTANGLE_H
#include <iostream>
class Rectangle : public Shape {
private:
int w, h;
public:
Rectangle() : Shape(), w(0), h(0) {
}
Rectangle(int x, int y, int w, int h) : Shape(x, y), w(w), h(h) {
}
double area() const {
return w*h;
}
void print() const {
std::cout << "Rectangle(" << x << ", " << y << ", " <<
w << ", " << h << ")" << std::endl;}
};
#endif //EXAMPLE14_RECTANGLE_H