![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
文章平均质量分 73
d99cnx
这个作者很懒,什么都没留下…
展开
-
设计模式Before-after之桥接模式
before.cxx#include class BlackCircle {public: void what(void) { std::cout << "a black circle." << std::endl; }};class BlackSquare {public: void what(void) { std::cout << "a black squar原创 2014-03-12 23:39:50 · 456 阅读 · 0 评论 -
设计模式Before-after之享元模式
before.cxx#include #include class ACounter {public: unsigned int count(const std::string &input) { unsigned int count = 0; for (int i = 0; i < input.length(); ++i) { if (input[i] == 'a' ||原创 2014-03-21 18:22:47 · 429 阅读 · 0 评论 -
设计模式Before-after之单例模式
before.cxx#include class OS {public: const char *getName(void) { return "Microsoft Windows"; } const char *getVersion(void) { return "6.1.7601"; }};OS os;void displayCurrentOSName(vo原创 2014-03-17 13:55:55 · 510 阅读 · 0 评论 -
设计模式Before-after之装饰模式
before.cxx#include class RobotCat {public: void cry(void) { std::cout << "Meow! Meow! Meow!" << std::endl; }};class RobotCatCanWalk: public RobotCat {public: void walk(void) { std::cou原创 2014-03-17 10:21:40 · 525 阅读 · 0 评论 -
设计模式Before-after之组合模式
before.cxx#include #include class Element {public: Element(int value): value(value) {}; void remove(void) { std::cout value << " has been removed." << std::endl; }private: int value;};原创 2014-03-15 00:35:10 · 554 阅读 · 0 评论 -
设计模式Before-after之简单工厂模式
before.cxx#include #include class Apple {public: void sayHello(void) { std::cout << "Hello, I'm a apple." << std::endl; }};class Banana {public: void sayHello(void) { std::cout << "He原创 2014-03-10 13:14:50 · 771 阅读 · 0 评论 -
设计模式Before-after之原型模式
before.cxx#include class Factorial {public: Factorial(unsigned int n) { double value = 1; for (unsigned int k = 2; k < n; ++k) { value *= k; } this->value = value; } void displayVal原创 2014-03-12 13:21:39 · 997 阅读 · 0 评论 -
设计模式Before-after之工厂方法模式
before.cxx#include #include class Apple {public: void sayHello(void) { std::cout << "Hello, I'm a apple." << std::endl; }};class Banana {public: void sayHello(void) { std::cout << "He原创 2014-03-10 15:49:29 · 561 阅读 · 0 评论 -
设计模式Before-after之抽象工厂模式
before.cxx#include #include class BlackCircle {public: void sayHello(void) { std::cout << "Hello, I'm a black circle." << std::endl; }};class BlackSquare {public: void sayGoodbye(void原创 2014-03-10 16:38:38 · 619 阅读 · 0 评论 -
设计模式Before-after之建造者模式
before.cxx#include #include class Shape {public: void setColor(const std::string &colorName) { this->colorName = colorName; } void setKind(const std::string &kindName) { this->kindName =原创 2014-03-10 23:50:25 · 520 阅读 · 0 评论 -
设计模式Before-after之适配器模式
before.cxx#include class Dog {public: void runAway(void) { std::cout << "HELP!!! Dog-god bless me!" << std::endl; }};class DogHunter {public: void hunt(Dog &dog) { dog.runAway(); }};原创 2014-03-12 20:10:53 · 477 阅读 · 0 评论 -
设计模式Before-after之代理模式
before.cxx#include #include class Console {public: void write(std::string msg) { std::cout << msg; }};int main(void) { Console console; console.write("hello"); console.write(", "); co原创 2014-04-01 23:39:23 · 577 阅读 · 0 评论