त्रुटि है this कोड में:अजीब त्रुटि
//myutil.h
template <class T, class predicate>
T ConditionalInput(LPSTR inputMessage, LPSTR errorMessage, predicate condition);
//myutil.cpp
template <class T, class Pred>
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
मैं घंटों के लिए इसे के साथ संघर्ष कर रहा है लेकिन एक समाधान खोजने के लिए प्रतीत नहीं हो सकता है। मेरा मानना है कि गलती छोटी हो सकती है, लेकिन मुझे किसी और परिस्थिति में त्रुटि का सामना करने में कोई और नहीं मिला। बहुत सराहना की मदद करें!
संपादित करें: फ्रेडरिक स्लिमकरमैन द्वारा किए गए सुधार एक मुद्दे को हल करता है लेकिन दूसरा बनाता है। इस बार त्रुटि है:
Error 1 error LNK2019: unresolved external symbol "int __cdecl ConditionalInput<int,class `anonymous namespace'::<lambda0> >(char *,char *,class `anonymous namespace'::<lambda0>)" ([email protected]<lambda0>@[email protected]@@@YAHPAD0V<lambda0>@[email protected]@@Z) referenced in function _main
कृपया मेरे साथ भालू और इस समस्या को हल करने में मेरी सहायता करें।
संपादित, <> को lt/gt द्वारा प्रतिस्थापित करने की आवश्यकता है। – Scharron
उपर्युक्त उत्तर की टिप्पणियों में सही उत्तर। हालांकि इस उपयोगकर्ता के लिए क्रेडिट है। – Johnny