Advertisement
ithoran

Untitled

Nov 30th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. // Window.h
  2. #pragma once
  3. #include <iostream>
  4. class Window {
  5. public:
  6.     char title[30];
  7.     bool state;
  8.     virtual void draw();
  9.     void open();
  10.     void close();
  11. };
  12.  
  13. // Window.cpp
  14. #include "Window.h"
  15. using namespace std;
  16. void Window::draw() {
  17.     cout << title;
  18.     cout << state;
  19. }
  20. void Window::open() {
  21.     state = true;
  22. }
  23. void Window::close() {
  24.     state = false;
  25. }
  26.  
  27. // DialogWindow.h
  28. #include "Window.h"
  29. class DialogWindow : public Window {
  30. public:
  31.     void draw();
  32.     int confirm();
  33.     int cancel();
  34. };
  35.  
  36. // DialogWindow.cpp
  37. #include "DialogWindow.h"
  38. using namespace std;
  39. void DialogWindow::draw() {
  40.     cout << "DialogWindow nacrtan\n";
  41. }
  42. int DialogWindow::confirm() {
  43.     close();
  44.     return 1;
  45. }
  46. int DialogWindow::cancel() {
  47.     close();
  48.     return 0;
  49. }
  50.  
  51. // DocumentWindow.h
  52. #include "Window.h"
  53. using namespace std;
  54. class DocumentWindow : public Window {
  55.     void draw() {
  56.         cout << "DocumentWindow nacrtan\n";
  57.     }
  58. };
  59.  
  60. // main
  61. #include "Window.h"
  62. #include "DialogWindow.h"
  63. #include "DocumentWindow.h"
  64. void main() {
  65.     Window *p1, *p2;
  66.     p1 = new DialogWindow;
  67.     p2 = new DocumentWindow;
  68.     p1->draw();
  69.     p1->open();
  70.     p1->close();
  71.     p2->draw();
  72.     p2->close();
  73.     p2->open();
  74.     delete[] p1, p2;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement