Template specialization fails on linking

前端 未结 3 1304
一生所求
一生所求 2021-02-15 12:10

I have an issue with template specialization which I would like to understand. I\'m working with Visual C++ 10.0 (2010). I have a class like this:

class Variable         


        
3条回答
  •  遇见更好的自我
    2021-02-15 12:55

    Method starting with template<> is still considered a template specialization method. So you must have to put into a header file.

    If you want to put it into a implementation file then you have to overload it.

    class VariableManager
    {
    //...
      VarT get(std::string const& name) const
      {}
    
      std::string get(std::string const& name) const; //overloading not specialization
    };
    

提交回复
热议问题