//a.cpp
template<typename... Args>
const char * convert(std::string fmt,Args ...)
{
const char* returnStr = fmt.c_str();
return returnStr;
}
//a.h
template<typename... Args>
const char * convert(std::string fmt,Args ...)
{
const char* returnStr = fmt.c_str();
return returnStr;
}
//initaliz3.cpp
void initialize()
{
pros::lcd::initialize();
pros::lcd::print(2,convert("hey"));
}
有一个错误[initialize.cpp :(。text.initialize + 0x3c):对`char const * convert <>(std :: __ cxx11 :: basic_string,std :: allocator>)的未定义引用” collect2.exe:错误:ld返回1退出状态]。但是,当我将模板函数粘贴到initialize.cpp中时,该函数有效。我如何正确地在a.h中进行函数声明?