home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / emx / test / test1.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-07  |  1.3 KB  |  95 lines

  1. #include <iostream.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. enum click {Down, Up};
  6.  
  7. class Window
  8. {
  9. public:
  10.   int handle;
  11.   Window();
  12.   virtual ~Window();
  13.   void Event(enum click event);
  14.   virtual void ButtonDown(void);
  15.   virtual void ButtonUp(void);
  16. };
  17.  
  18. Window::Window()
  19. {
  20.   printf("Window constructor called\n");
  21.   handle = 1;
  22. }
  23.  
  24. Window::~Window()
  25. {
  26.   printf("Window destructor called\n");
  27. }
  28.  
  29. void Window::Event(enum click event)
  30. {
  31.   event == Down ? ButtonDown() : ButtonUp();
  32. }
  33.  
  34. void Window::ButtonDown(void)
  35. {
  36.   printf("Window::ButtonDown() called\n");
  37. }
  38.  
  39. void Window::ButtonUp(void)
  40. {
  41.   printf("Window::ButtonUp() called\n");
  42. }
  43.  
  44.  
  45. class MyWindow : public Window
  46. {
  47. public:
  48.   MyWindow();
  49.   virtual ~MyWindow();
  50.   virtual void ButtonDown(void);
  51. };
  52.  
  53. MyWindow::MyWindow()
  54. {
  55.   printf("MyWindow constructor called\n");
  56.   handle = 2;
  57. }
  58.  
  59. MyWindow::~MyWindow()
  60. {
  61.   printf("MyWindow destructor called\n");
  62. }
  63.  
  64. void MyWindow::ButtonDown(void)
  65. {
  66.   printf("MyWindow::ButtonDown() called\n");
  67. }
  68.  
  69.  
  70. Window sWindow;
  71. MyWindow sMyWindow;
  72.  
  73.  
  74. int main(void)
  75. {
  76.   Window Test;
  77.   MyWindow MyTest;
  78.   MyWindow *pMyTest;
  79.  
  80.   printf("Main called\n");
  81.  
  82.   pMyTest = new MyWindow;
  83.  
  84.   Test.Event(Down);
  85.   Test.Event(Up);
  86.   MyTest.Event(Down);
  87.   MyTest.Event(Up);
  88.  
  89.   delete pMyTest;
  90.  
  91.   printf("Main left\n");
  92.  
  93.   return 0;
  94. }
  95.