【发布时间】:2011-10-18 20:02:02
【问题描述】:
我正在尝试对向量进行模板化。我主要有以下几点:
std::vector<Word> concordance = push_vector(data);
其中 Word 是包含 std::string 和 int 的结构,而 data 是 std::string。在我的头文件中,我有:
template <typename T>
std::vector<T> push_vector(std::string&);
但是当我编译时出现以下错误:
main.cpp: In function ‘int main(int, char**)’:
main.cpp:27:53: error: no matching function for call to ‘push_vector(std::string&)’
main.cpp:27:53: note: candidate is:
templates.h:13:20: note: template<class T> std::vector<T> push_vector(std::string&)
我知道我在实现模板功能时遗漏了一些东西,但我不确定是什么。提前感谢您的宝贵时间。
【问题讨论】: