Advertisement
ewelina_r

ex33

Jun 21st, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. class Wypisz
  2. {
  3. public:
  4.     void operator()(int) const;
  5. };
  6.  
  7. void Wypisz::operator()(int liczba) const
  8. {
  9.     cout << liczba << "\n";
  10. }
  11.  
  12.  
  13. template <class T, class UnaryFunction>
  14. void forEach(List<T> const & l, UnaryFunction f)
  15. {
  16.     typename List<T>::wezel * pom = l.Poczatek();
  17.     while (pom)
  18.     {
  19.         f(pom->element);
  20.         pom = pom->nast;
  21.     }
  22. }
  23.  
  24. int main()
  25. {
  26.     List<int> lst;
  27.     Wypisz f;
  28.  
  29.     forEach(lst, f);
  30.  
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement