Yurttas/PL/OOL/Cplusplus/F/04/03/00/vector e 00.cpp
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 vector_e_00.cpp
14*/
15
16
17#include <iostream>
18
19#include <vector>
20
21using namespace std;
22
23#include "vector_e.cpp"
24
25int main(int argc, char* argv[]) {
26
27 vector_e<int> a_0(2,
28 9);
29
30 cout << "initial values after construction /";
31 cout << endl;
32 cout << "a_0 :";
33 cout << endl;
34 cout << a_0;
35 cout << endl;
36
37 vector_e<int> a_1(4,
38 1);
39
40 cout << "initial values after construction /";
41 cout << endl;
42 cout << "a_1 :";
43 cout << endl;
44 cout << a_1;
45 cout << endl;
46
47 int n = a_1.get_size();
48
49 cout << "a_1.get_element(i) /";
50 cout << endl;
51
52 for(int i=0; i<n; i++)
53 cout << a_1.get_element(i) << endl;
54 cout << endl;
55
56 a_1.set_element(0,
57 6);
58
59 vector<int> a = a_1.get_element(0,2);
60
61 n = a.size();
62
63 cout << "a_1.get_element(0,2) /";
64 cout << endl;
65
66 for(int i=0; i<n; i++)
67 cout << a[i] << endl;
68 cout << endl;
69
70 a_1[2] = 7;
71 cout << "a_1[2] /";
72 cout << endl;
73 cout << a_1[2];
74 cout << endl;
75
76 cout << "a_1 :";
77 cout << endl;
78 cout << a_1;
79 cout << endl;
80
81 vector_e<int> a_2(a_1);
82
83 cout << "initial values after copy construction /";
84 cout << endl;
85 cout << "a_2 :";
86 cout << endl;
87 cout << a_2;
88 cout << endl;
89
90 a_2 = a_0;
91
92 cout << "initial values after a_2=a_0 /";
93 cout << endl;
94 cout << "a_2 :";
95 cout << endl;
96 cout << a_2;
97 cout << endl;
98
99}