64,684
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
using namespace std;
template <typename Type>
void printElements(const Type& col)
{
for(const auto &item : col){
cout << item << endl;
}
}
int main()
{
auto a = {1, 2, 3, 4};
printElements(a); //OK
printElements({1, 2, 3, 4}); //ERROR: couldn't deduce template parameter ‘Type’
return 0;
}