C++组合和访问者模式一起实现的示例
现在我正在开发一个专门的矢量编辑器。你能告诉我在哪里可以看到源代码(非标准书籍示例)实现组合和访问者模式的一个很好的示例(仅限 C++ 语言)。
Now I'm developing a 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
复合+访问者并不是那么受欢迎的一对,在大多数情况下你可以看到复合+迭代器......所以你必须尝试自己动手添加它们,但这应该不难。在这两种模式中,您都有由具体类实现的接口,因此您必须用访问者的想法来填充您的组合
http: //sourcemaking.com/design_patterns/composite/cpp/2
http://sourcemaking. com/design_patterns/composite/cpp/1
http://sourcemaking.com/design_patterns/visitor
格:)
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:
此示例源代码基于《Pattern Hatching》一书中的文件系统示例:应用设计模式,作者:John Vlissides,它使用 Composite 和 Visitor。 (该代码包括书中未包含的外部迭代器)。
详细介绍书中示例的免费幻灯片位于 使用模式进行设计。
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.