[ create a new paste ] login | about

Link: http://codepad.org/N5JWb2GC    [ raw code | output | fork ]

C++, pasted on Nov 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
template <class Arg>
class isEven: public std::unary_function<Arg, bool> {
public:
  result_type operator() (argument_type i) {
    return (result_type) !(i % 2);
  }
};
int main() {
  std::vector<int> v;
  for (int i = 0; i < 20; i++) v.push_back(i);
  for (int i = 0; i < v.size(); i++) std::cout << v[i] << " ";
  std::cout << std::endl;
  int i = count_if(v.begin(), v.end(), isEven<int>());
  std::cout << "i = " << i << std::endl;
  return 0;
}
/* end */


Output:
1
2
Line 8: error: ISO C++ forbids declaration of 'result_type' with no type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: