#include <iostream>
#include <string>

class shape
{
public:
    void setValues(int height_, int width_)
    {
        height = height_;
        width = width_;
    }

    virtual int area() = 0;  // This is needed for polymorphism to work

    virtual std::string name() = 0;

protected:
    int height;
    int width;
};

class rectangle : public shape
{
public:
    int area()
    {
        return height * width;
    }

    std::string name()
    {
        return "Rectangle";
    }
};

class triangle :public shape
{
public:
    int area()
    {
        return height * width / 2;
    }

    std::string name()
    {
        return "Triangle";
    }
};

void print_area(shape& poly)
{
    std::cout << poly.name() << ' ' << poly.area() << '\n';
}

int main()
{
    rectangle rect;
    triangle trng;

    rect.setValues(2, 3);
    trng.setValues(5, 4);

    print_area(rect);
    print_area(trng);
}
