工厂模式C++11泛型实现

来源:互联网 发布:网络销售总结怎么写 编辑:程序博客网 时间:2024/06/05 17:29

#include <unordered_map>
#include <typeindex>
#include <functional>

typedef std::function<IObject* (Type param)> ObjectFactoryFunc; // 声明工厂函数,在继承体系各类中实现static Create(Type param)


typedef std::unordered_map<std::type_index, ObjectFactoryFunc> ObjectFactoryHashmap; // 在这里注册Create

怎么使用,你懂的!

0 0
原创粉丝点击