类成员函数定义错误

时间:2015-09-04 17:29:06

标签: c++ visual-studio visual-studio-2012

我在VisualStudio2013中编译了以下代码。 我在layer_factory.hpp中有一个类,如

namespace caffe {

    template <typename Dtype>
    class Layer;

    template <typename Dtype>
    class LayerRegistry {
     public:
         typedef shared_ptr<Layer<Dtype> >(*Creator) (const LayerParameter&);
         typedef std::map<string, Creator> CreatorRegistry;

         static CreatorRegistry& Registry();

    }

}

我将Registry()中的layer_factory.cpp定义为

namespace caffe {
    template <typename Dtype>
    static LayerRegistry<Dtype>::CreatorRegistry& LayerRegistry<Dtype>::Registry()
    {
        static CreatorRegistry* g_registry_ = new CreatorRegistry();
        return *g_registry_;
    }
}

当我编译时,我得到错误

Error   23  error C1903: unable to recover from previous error(s); stopping compilation C:\SOFTWARES\Visual_Studio_Workspace\caffe\src\caffe\layer_factory.cpp  23  1   caffe
Error   20  error C2065: 'Dtype' : undeclared identifier    C:\SOFTWARES\Visual_Studio_Workspace\caffe\src\caffe\layer_factory.cpp  19  1   caffe
Error   19  error C2143: syntax error : missing ';' before '&'  C:\SOFTWARES\Visual_Studio_Workspace\caffe\src\caffe\layer_factory.cpp  19  1   caffe
Error   22  error C2509: 'Registry' : member function not declared in 'caffe::LayerRegistry'    C:\SOFTWARES\Visual_Studio_Workspace\caffe\src\caffe\layer_factory.cpp  23  1   caffe
Error   21  error C2923: 'caffe::LayerRegistry' : 'Dtype' is not a valid template type argument for parameter 'Dtype'   C:\SOFTWARES\Visual_Studio_Workspace\caffe\src\caffe\layer_factory.cpp  19  1   caffe

这段代码有什么问题? 感谢

0 个答案:

没有答案