我收到的编译错误是
could not deduce template argument for 'std::vector<T*>&' from 'std::vector<_Ty>'
template <typename T> void foo(vector<T*>& a, int left, int right)
{
...
}
main()
{
...
//declare and instantiate 3 vectors
vector<int> intVector;
foo(intVector, 0, 100);
foo(doubleVector, 0, 100);
foo(charVector, 0, 100);
...
}
答案 0 :(得分:0)
int
无法匹配T*
。
将vector
设为vector<int*>
或将模板设为vector<T>
。