W
webinfinite
This is my first post here, please tell me if I did anything wrong.
in the following code snippet:
1. template <class In, class Pred>
2. In find_if(In begin, In end, Pred f) {
3. while (begin != end && !f(*begin))
4. ++begin;
5. return begin;
6. }
7. bool is_negative(int n) {
8. return n < 0;
9. }
10. vector<int>::iterator i = find_if(v.begin(), v.end(),
is_negative);
find_if is the template needs a class Pred as its third argument but
in line 10's function call, it takes a function poniter is_negative,
does that mean in C++, function point is equivalent to class?
Thank you.
in the following code snippet:
1. template <class In, class Pred>
2. In find_if(In begin, In end, Pred f) {
3. while (begin != end && !f(*begin))
4. ++begin;
5. return begin;
6. }
7. bool is_negative(int n) {
8. return n < 0;
9. }
10. vector<int>::iterator i = find_if(v.begin(), v.end(),
is_negative);
find_if is the template needs a class Pred as its third argument but
in line 10's function call, it takes a function poniter is_negative,
does that mean in C++, function point is equivalent to class?
Thank you.