我的基于模板的工厂和工厂注册有问题: factory.h
#ifndef INCLUDED_FACTORY
#define INCLUDED_FACTORY
#include <map>
#include <string>
#include <boost/shared_ptr.hpp>
namespace common_utils {
template<class bT>
class Creator
{
public:
virtual bT* create() = 0;
};
template <class bT>
struct CreatorPtr
{
typedef boost::shared_ptr< Creator<bT> > type;
};
template <class bT, class cT>
class CreatorImpl : public Creator<bT>
{
public:
virtual bT* create() { return new cT; }
};
factory_register.h
#ifndef INCLUDED_FACTORYREGISTER
#define INCLUDED_FACTORYREGISTER
#include <factory.h>
namespace common_utils {
template<class eT, class bT, class cT>
class FactoryRegister
{
public:
FactoryRegister();
private:
FactoryRegister(const FactoryRegister&) {};
FactoryRegister& operator=(const FactoryRegister&) {};
};
} // namespace common_utils
现在我收到了这样的编译错误:
factory_register.h:在构造函数'common_utils :: FactoryRegister :: FactoryRegister()'中: factory_register.h:15:错误:预期`;&#39;在'创造者'之前 factory_register.h:16:错误:未在此范围内声明'creator'
似乎无法识别CreatorPtr<bT〉::type
。有人可以提供任何见解吗?
感谢。