All pastes #136891 Raw Edit

Miscellany

public cpp v1 · immutable
#136891 ·published 2006-08-18 00:17 UTC
rendered paste body
#include <iostream>using namespace std;class Writer {  public:    virtual void write(char *text) {       printf("%s", text);    }};class DecoratorWriter: public Writer{	protected:		Writer *_writer;	public:		DecoratorWriter(Writer *writer) : _writer(writer) {}                virtual void write(char *text) {                   printf("%s", text);                }};class DecoratorHTML: public DecoratorWriter {   public:     void write(char *text) {        printf("<!-- HTML para %s -->", text);        printf("<html><body><p>");	_writer->write(text);        printf("</p></body></html>");     } };class DecoratorLinkHTML : public DecoratorWriter {   private:     char* _reference;   public:     DecoratorLinkHTML(Writer *writer, const char* reference) : _writer(writer), _reference(reference) {}     void write(char *text) {        printf("<!-- Link para %s -->", text);        printf("<a href=\"#\"%s\">", reference);        _writer->write(text);        printf("</a>");     }}int main() {  Writer *normal = new DecoratorHTML(new DecoratorLinkHTML(new Writer()));  normal.write("Seu Texto aqui!!");  return 0;}