Yurttas/PL/OOL/Cplusplus/F/04/03/00/t 03.cpp

From ZCubes Wiki
Revision as of 23:33, 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)
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   t_00.cpp
14*/
15
16
17#include <iostream>
18
19#include <vector>
20
21using namespace std;
22
23#include "vector_e.h"
24
25template <class T>
26void t_00(vector_e<T>& a,
27          const T b) {
28  cout << "initial values after construction /" << endl;
29  cout << "a :" << endl;
30  cout << a << endl;
31  cout << endl;
32
33  int n = a.get_size();
34
35  cout << "a.get_element(i) /" << endl;
36
37  for(int i=0; i<n; i++)  
38    cout << a.get_element(i) << endl;
39  cout << endl;
40
41  a.set_element(0,b);
42
43  vector<T> t = a.get_element(0,1);
44
45  n = t.size();
46
47  cout << "a.get_element(0,1) /" << endl;
48
49  for(int i=0; i<n; i++)  
50    cout << t[i] << endl;
51  cout << endl;
52
53  a[1] = b;
54  cout << "a[1] /" << endl;
55  cout << a[1] << endl;
56  cout << endl;
57
58  cout << "a :" << endl;
59  cout << a << endl;
60  cout << endl;
61
62  vector_e<T> c(a);
63
64  cout << "initial values after copy construction /" << endl;
65  cout << "c :" << endl;
66  cout << c << endl;
67  cout << endl;
68
69  c = a;
70
71  cout << "initial values after c=a /" << endl;
72  cout << "c :" << endl;
73  cout << c << endl;
74  cout << endl;
75}