Thread: Decorator

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248

    Decorator

    Hi,

    To clean up a class which contains too many fonctions and attributes, I want to implement decorators for that class.
    However, the class contains many virtual functions.

    If I understood well, I should re-implement all these virtual functions as (suppose I do not derive further from my decorator) :

    Code:
    class to_be_decorated {
     public:
      virtual bool foo();
    };
    
    class decorator : public to_be_decorated {
     public:
      decorator(class to_be_decorated&);
      bool foo() { return obj.foo(); }
     private:
      to_be_decorated& obj;
    };
    Am I right ?

    This will cause my simple decorators to become quite cumbersome as well... any other solutions or ideas?

    Thanks!!

    Mark
    Last edited by MarkZWEERS; 08-03-2009 at 10:01 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visitor / Decorator Pattern
    By MarkZWEERS in forum C++ Programming
    Replies: 9
    Last Post: 05-16-2009, 11:53 AM
  2. Composite vs Decorator pattern?
    By cpjust in forum Tech Board
    Replies: 1
    Last Post: 04-22-2009, 11:33 AM
  3. Decorator Help
    By King Mir in forum C++ Programming
    Replies: 7
    Last Post: 06-14-2006, 12:18 PM