Yurttas/PL/OOL/Cplusplus/F/01/02/iterator/00/iter 01.cpp

Revision as of 20:46, 6 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="cpp" line start="1" enclose="div">/* Copyright(C) 2002 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. Perm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 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_01.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  i_first = v.begin();
39
40  for(; i_first!=i_last; i_last--)
41    cout << *(i_last-1) << endl;
42
43}