在C ++中的装饰器模式 [英] Decorator pattern in C++

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

问题描述

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

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设计模式,尽管其布局很差,但是对于大多数设计模式

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

点击装饰

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

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆