Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Window.h
- #pragma once
- #include <iostream>
- class Window {
- public:
- char title[30];
- bool state;
- virtual void draw();
- void open();
- void close();
- };
- // Window.cpp
- #include "Window.h"
- using namespace std;
- void Window::draw() {
- cout << title;
- cout << state;
- }
- void Window::open() {
- state = true;
- }
- void Window::close() {
- state = false;
- }
- // DialogWindow.h
- #include "Window.h"
- class DialogWindow : public Window {
- public:
- void draw();
- int confirm();
- int cancel();
- };
- // DialogWindow.cpp
- #include "DialogWindow.h"
- using namespace std;
- void DialogWindow::draw() {
- cout << "DialogWindow nacrtan\n";
- }
- int DialogWindow::confirm() {
- close();
- return 1;
- }
- int DialogWindow::cancel() {
- close();
- return 0;
- }
- // DocumentWindow.h
- #include "Window.h"
- using namespace std;
- class DocumentWindow : public Window {
- void draw() {
- cout << "DocumentWindow nacrtan\n";
- }
- };
- // main
- #include "Window.h"
- #include "DialogWindow.h"
- #include "DocumentWindow.h"
- void main() {
- Window *p1, *p2;
- p1 = new DialogWindow;
- p2 = new DocumentWindow;
- p1->draw();
- p1->open();
- p1->close();
- p2->draw();
- p2->close();
- p2->open();
- delete[] p1, p2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement