1.单例模式
构造函数私有化,用静态方法返回一个静态指针。
2.策略模式
策略类的构造函数形参为实际要用的子类对象,实现多态,在策略类中调用虚函数。
3.工厂模式
不同的子工厂返回不同的产品类对象,用父产品指向这些对象,并调用虚函数。
4.模板方法模式
模板父类中声明虚函数,以及定义这些虚函数的调用次序的函数,用指向不同子类对象的父指针调用上述函数。
5.外观模式
将很多的类方法调用进行组合封装,只需调用外观类即可完成需要的类方法调用。