Skip to content

Instantly share code, notes, and snippets.

@BlaiseRideout
Created August 1, 2013 22:31
Show Gist options
  • Select an option

  • Save BlaiseRideout/6135941 to your computer and use it in GitHub Desktop.

Select an option

Save BlaiseRideout/6135941 to your computer and use it in GitHub Desktop.
#include "Process.hpp"
Process::Process() {
}
Process::~Process() {
}
void Process::execute() {
this->init();
}
#ifndef PROCESS_HPP_
#define PROCESS_HPP_
class Process {
public:
Process();
virtual ~Process();
void execute();
virtual void init() = 0;
};
#endif /* PROCESS_HPP_ */
#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;
}
#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_ */
#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;
}
#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