Advertisement
Guest User

Untitled

a guest
Jul 24th, 2010
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. template <class T, class Pred>
  2. T ConditionalInput(LPSTR inputMessage, LPSTR errorMessage, Pred condition)
  3. {
  4.     T input
  5.     cout<< inputMessage;
  6.     cin>> input;
  7.     while(!condition(input))
  8.     {
  9.         cout<< errorMessage;
  10.         cin>> input;
  11.     }
  12.     return input;
  13. }
  14.  
  15. ...
  16.  
  17. int row;
  18.  
  19. 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; });
  20.  
  21. ...
  22.  
  23. The error is:
  24.  
  25. Error   1   error C2783: 'T ConditionalInput(LPSTR,LPSTR,predicate)' : could not deduce template argument for 'T' c_main.cpp    17  1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement