summaryrefslogtreecommitdiff
path: root/c,cc/delegate_iterator.cc
blob: c4e272ee55a1ce0374138a81432368f724290839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <vector>

using namespace std;

class A {
  private:
    typedef vector<int> Data;
    Data data_;
  public:
    typedef Data::iterator iterator;
    typedef const Data::iterator const_iterator;
    iterator begin() { return data_.begin(); }
    iterator end() { return data_.end(); }

    void add(int i) {
      data_.push_back(i);
    }
};

int
main(void)
{
  A a;
  a.add(23);
  for (A::iterator it = a.begin(); it != a.end(); it++) {
    cout << *it << endl;
  }

  return 0;
}