C++ example of implementation composite and visitor pattern together
Now I'm developing 开发者_StackOverflowa specialized vector editor. Can you tell me where I can see a good example (only C++ language ) of source (not standard book example) implementation composite and visitor pattern together.
Composite + visitor isn't such a popular pair, in most cases you can see composite + iterator ... so you will have to try add them by your own hands, but it shouldn't be hard. In both patterns you have inteface implemented by concrete classes, so you have to fill your composite with visitor ideas
http://sourcemaking.com/design_patterns/composite/cpp/2
http://sourcemaking.com/design_patterns/composite/cpp/1
http://sourcemaking.com/design_patterns/visitor
gl :)
A quick google search gave me these implementation examples of Composite Pattern:
- C++ example for Composite Design Pattern
- Composite design pattern
- Composite design pattern - multiple container classes
- Composite Pattern Made as C++ Component
This example source code is based upon the file system example found in the book Pattern Hatching: Design Patterns Applied, by John Vlissides, which uses Composite and Visitor. (The code includes external iterator that is not in the book).
Free slides detailing the example from the book are at Designing with Patterns.
精彩评论