#include <iostream.h>
#include <stdio.h>


enum click {Down, Up};

class Window
{
public:
  int handle;
  Window();
  virtual ~Window();
  void Event(enum click event);
  virtual void ButtonDown(void);
  virtual void ButtonUp(void);
};

Window::Window()
{
  printf("Window constructor called\n");
  handle = 1;
}

Window::~Window()
{
  printf("Window destructor called\n");
}

void Window::Event(enum click event)
{
  event == Down ? ButtonDown() : ButtonUp();
}

void Window::ButtonDown(void)
{
  printf("Window::ButtonDown() called\n");
}

void Window::ButtonUp(void)
{
  printf("Window::ButtonUp() called\n");
}


class MyWindow : public Window
{
public:
  MyWindow();
  virtual ~MyWindow();
  virtual void ButtonDown(void);
};

MyWindow::MyWindow()
{
  printf("MyWindow constructor called\n");
  handle = 2;
}

MyWindow::~MyWindow()
{
  printf("MyWindow destructor called\n");
}

void MyWindow::ButtonDown(void)
{
  printf("MyWindow::ButtonDown() called\n");
}


Window sWindow;
MyWindow sMyWindow;


int main(void)
{
  Window Test;
  MyWindow MyTest;
  MyWindow *pMyTest;

  printf("Main called\n");

  pMyTest = new MyWindow;

  Test.Event(Down);
  Test.Event(Up);
  MyTest.Event(Down);
  MyTest.Event(Up);

  delete pMyTest;

  printf("Main left\n");

  return 0;
}
