【发布时间】:2018-03-23 07:01:09
【问题描述】:
我在尝试构建代码时收到以下错误。
src/Test.cxx:29:错误:'模板 T 的特化 com::check::one::Test::getValue(const std::string&)' 在不同的 命名空间 ./incl/Test.hxx:30:错误:来自定义 '模板 T com::check::one::Test::getValue(const std::string&)' src/Test.cxx:31: 被之前的错误弄糊涂了,放弃 出去
头文件:
namespace com::check::one
{
class Test
{
public:
template<typename T>
T getValue(const std::string& var);
};
}
源文件:
using namespace com::check::one;
template<>
std::vector<std::string> Test::getValue(const std::string& var)
{
//statements
}
我使用了正确的命名空间并包含了头文件。编译没有问题。即使我在源文件中定义了测试类的其他成员函数。这些功能没有问题。只有具有模板的此功能存在问题。错误是在构建期间。谁能帮我解决这个问题?
【问题讨论】: