Ошибка находится в этом коде:
//myutil.h
template
T ConditionalInput(LPSTR inputMessage, LPSTR errorMessage, predicate condition);
//myutil.cpp
template
T ConditionalInput(LPSTR inputMessage, LPSTR errorMessage, Pred condition)
{
T input
cout<< inputMessage;
cin>> input;
while(!condition(input))
{
cout<< errorMessage;
cin>> input;
}
return input;
}
...
//c_main.cpp
int row;
row = ConditionalInput("Input the row of the number to lookup, row > 0: ",
"[INPUT ERROR]: Specified number is not contained in the range [row > 0]. "
"Please type again: ", [](int x){ return x > 0; });
Ошибка:
Error 1 error C2783: 'T ConditionalInput(LPSTR,LPSTR,predicate)' :
could not deduce template argument for 'T' c_main.cpp 17 1
Я боролся с ним в течение многих часов, но, может казаться, не нахожу решение. Я полагаю, что ошибка могла бы быть тривиальной, но я не мог найти никого больше встречающегося с ошибкой при подобных обстоятельствах. Помогите многому ценившему!
Править: Исправление, сделанное Frederik Slijkerman, устраняет одну проблему, но создает другого. На этот раз ошибка:
Error 1 error LNK2019: unresolved external symbol "int __cdecl ConditionalInput >(char *,char *,class `anonymous namespace'::)" (??$ConditionalInput@HV@?A0x109237b6@@@@YAHPAD0V@?A0x109237b6@@@Z) referenced in function _main
Терпите меня и помогите мне решить эту проблему.