Created
August 1, 2013 22:31
-
-
Save BlaiseRideout/6135941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "Process.hpp" | |
| Process::Process() { | |
| } | |
| Process::~Process() { | |
| } | |
| void Process::execute() { | |
| this->init(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef PROCESS_HPP_ | |
| #define PROCESS_HPP_ | |
| class Process { | |
| public: | |
| Process(); | |
| virtual ~Process(); | |
| void execute(); | |
| virtual void init() = 0; | |
| }; | |
| #endif /* PROCESS_HPP_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include "Screen.hpp" | |
| Screen::Screen() { | |
| Screen(320); | |
| } | |
| Screen::Screen(unsigned int w) : width(w) { | |
| std::cout << "Screen(): " << this->width << std::endl; | |
| } | |
| Screen::~Screen() { | |
| } | |
| void Screen::init() { | |
| std::cout << "Screen::init(): " << this->width << std::endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef SCREEN_HPP_ | |
| #define SCREEN_HPP_ | |
| #include "Process.hpp" | |
| class Screen : public Process { | |
| public: | |
| Screen(); | |
| Screen(unsigned int); | |
| virtual ~Screen(); | |
| void init(); | |
| unsigned int width; | |
| }; | |
| #endif /* SCREEN_HPP_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include "System.hpp" | |
| System::System() { | |
| std::cout << "System(): " << this->s.width << std::endl; | |
| } | |
| System::~System() { | |
| } | |
| void System::init() { | |
| std::cout << "System::init(): " << this->s.width << std::endl; | |
| this->s.execute(); | |
| } | |
| int main(int argc, char **argv) { | |
| System s; | |
| s.execute(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef SYSTEM_HPP_ | |
| #define SYSTEM_HPP_ | |
| #include "Process.hpp" | |
| #include "Screen.hpp" | |
| class System : public Process { | |
| public: | |
| System(); | |
| virtual ~System(); | |
| void init(); | |
| Screen s; | |
| }; | |
| #endif /* SYSTEM_HPP_ */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment