Yurttas/PL/OOL/Cplusplus/F/07/01/02/00/l 01.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   l_01.cpp
14*/
15
16
17#include <iostream>
18#include <list>
19
20using namespace std;
21
22int main(int argc, char* argv[]) {
23
24  list<int> l_a;
25
26  l_a.push_back(3);
27  l_a.push_back(2);
28  l_a.push_back(4);
29  l_a.push_back(7);
30
31  list<int>::iterator i1 = l_a.begin();
32  list<int>::iterator i2 = l_a.end();
33
34  while(i1!=i2)
35    cout << *i1++ << endl;
36
37  cout << endl;
38
39  list<int> l_b;
40
41  l_b.push_back(1);
42  l_b.push_back(0);
43  l_b.push_back(6);
44  l_b.push_back(8);
45
46  i1 = l_b.begin();
47  i2 = l_b.end();
48
49  while(i1!=i2)
50    cout << *i1++ << endl;
51
52  cout << endl;
53
54  i1 = l_a.begin();
55
56  l_a.splice(i1, l_b);
57
58  i1 = l_a.begin();
59  i2 = l_a.end();
60
61  while(i1!=i2)
62    cout << *i1++ << endl;
63
64  cout << endl;
65
66}