This functions counts the number of occurences of 'val' inside the type C.Code:template <class C, class T> int count2(const C &v, T val) { C::const_iterator i = find(v.begin(), v.end(), val); int n = 0; while(i != v.end()) { ++n; ++i; i = find(i, v.end(), val); } return n; }
What i dont understand is why do i get compile error for this that i is undeclared...