Yurttas/PL/OOL/Cplusplus/F/07/04/00/iter 02.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2002
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : June 1, 2002.
11   author : Salih Yurttas.
12
13   iter_02.cpp
14*/
15
16
17#include <iostream>
18#include <vector>
19#include <string>
20
21using namespace std;
22
23int main(int argc, char* argv[]) {
24
25  vector<string> v;
26
27  v.push_back("watermelon");
28  v.push_back("strawberry");
29
30  vector<string>::iterator i_first = v.begin();
31  vector<string>::iterator i_last = v.end();
32
33  for(; i_first!=i_last; i_first++)
34    cout << *i_first << endl;
35
36  cout << endl;
37
38  vector<string>::reverse_iterator j_first = v.rbegin();
39  vector<string>::reverse_iterator j_last = v.rend();
40
41  for(; j_first!=j_last; j_first++)
42    cout << *j_first << endl;
43
44}