本文介绍了C ++中的装饰图案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我一个C ++中的Decorator模式的例子吗?
我遇到了Java版本。但是C ++我发现很难理解给出的例子。

解决方案

文斯·休斯顿设计模式尽管布局不好,但对于四人帮中的大多数设计模式都有C ++实现。



点击



除了手动内存处理,最好用智能指针包装之外,与Java没有太大区别:)


Can someone give me an example of Decorator pattern in C++ ?I have come across the Java version of it. But C++ i have found it difficult to understand the examples that are given.

解决方案

Vince Huston Design Patterns, even though its layout is poor, has C++ implementation for most design patterns in the Gang of Four book.

Click for Decorator.

There isn't much difference with Java, except the manual memory handling that you'd better wrap with smart pointers :)

这篇关于C ++中的装饰图案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 11:21