June 2017
Intermediate to advanced
532 pages
12h 59m
English
In this section, we will implement a primitive iterator that counts numbers and use it together with an STL algorithm, which initially does not compile with it. Then we do what's necessary to make it STL-compatible.
#include <iostream> #include <algorithm>
class num_iterator { int i; public: explicit num_iterator(int position = 0) : i{position} {} int operator*() const { return i; } num_iterator& operator++() { ++i; return *this; } bool operator!=(const num_iterator ...Read now
Unlock full access