// esim4.cpp
#include <iostream>
#include <string>

using namespace std;

// abstrakti rajapintaluokka
class Shape {

public:

    virtual void piirra() = 0; // puhdas virtuaalifunktio
        
    Shape() {} // Oletusmuodostin
    virtual ~Shape() {} // virtuaalinen hajotin
};

class Square : public Shape {

public:
    void piirra() {
        cout << "Piirtelee nelit..." << endl;
    }

    Square() {
        cout << "Neli-muodostin" << endl;
    }

    ~Square() {
        cout << "Neli-hajotin" << endl;
    }
};

class Circle : public Shape {

public:
    void piirra() {
        cout << "Piirtelee ympyr..." << endl;
    }

    Circle() {
        cout << "Ympyr-muodostin" << endl;
    }

    ~Circle() {
        cout << "Ympyr-hajotin" << endl;
    }
};

int main (void) {
    Shape *ps1 = new Square();
    Shape *ps2 = new Circle();

    if (ps1)
    {
        ps1->piirra();
        delete ps1;
        ps1 = NULL;
    }
    
    if (ps2)
    {
        ps2->piirra();
        delete ps2;
        ps2 = NULL;
    }

    return(0);

}