Yurttas/PL/OOL/Cplusplus/F/05/02/00/t a 02.cpp

From ZCubes Wiki
Revision as of 22:43, 6 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="cpp" line start="1" enclose="div">/* Copyright(C) 1998 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) 1998
  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   : January 1, 1998.
 11   author : Salih Yurttas.
 12
 13   t_a_02.cpp
 14*/
 15
 16
 17#include <iostream>
 18
 19using namespace std;
 20
 21#include "T_A.cpp"
 22
 23int main(int argc, char* argv[]) {
 24
 25  T_A<int,2> a_0;
 26
 27  cout << "a_0 values after construction-T_A() /" << endl;
 28  cout << a_0 << endl;
 29  cout << endl;
 30
 31  a_0.set_d(4);
 32
 33  cout << "a_0 values after a_0.set_d(2) /" << endl;
 34  cout << a_0 << endl;
 35  cout << endl;
 36
 37  a_0.set_d(8);
 38
 39  a_0.set_d(0,
 40            3);
 41
 42  a_0.set_d(3,
 43            9);
 44
 45  a_0.set_d(2,
 46            6);
 47
 48  a_0.set_d(7,
 49            7);
 50
 51  int n = a_0.get_s();
 52
 53  int* aa = new int[n];
 54
 55  aa = a_0.get_d();
 56
 57  cout << "aa after a_0.get_d() /" << endl;
 58  for(int i=0; i<n; ++i)
 59    cout << aa[i] << endl;
 60
 61  cout << endl;
 62
 63  T_A<int,2> a_1(a_0);
 64
 65  cout << "a_1 values after construction-T_A(const T_A&) /" << endl;
 66  cout << a_1 << endl;
 67  cout << endl;
 68
 69  a_1.set_d(2,
 70            4);
 71
 72  a_1.set_d(3,
 73            7);
 74
 75  cout << "a_1 after updated by (3,7) /" << endl;
 76  cout << a_1 << endl;
 77  cout << endl;
 78
 79  a_1 = a_0;
 80
 81  cout << "a_1 after a_1=a_0 /" << endl;
 82  cout << a_1 << endl;
 83  cout << endl;
 84
 85  cout << "a_0 after a_1=a_0 /" << endl;
 86  cout << a_0 << endl;
 87  cout << endl;
 88
 89  T_A<double,2> b_0;
 90
 91  cout << "b_0 values after construction-T_A() /" << endl;
 92  cout << b_0 << endl;
 93  cout << endl;
 94
 95  b_0.set_d(4);
 96
 97  cout << "b_0 values after b_0.set_d(2) /" << endl;
 98  cout << b_0 << endl;
 99  cout << endl;
100
101  b_0.set_d(8);
102
103  b_0.set_d(0,
104            3);
105
106  b_0.set_d(3,
107            9);
108
109  b_0.set_d(2,
110            6);
111
112  b_0.set_d(7,
113            7);
114
115  n = b_0.get_s();
116
117  double* bb = new double[n];
118
119  bb = b_0.get_d();
120
121  cout << "bb after b_0.get_d() /" << endl;
122  for(int i=0; i<n; ++i)
123    cout << bb[i] << endl;
124
125  cout << endl;
126
127  T_A<double,2> b_1(b_0);
128
129  cout << "b_1 values after construction-T_A(const T_A&) /" << endl;
130  cout << b_1 << endl;
131  cout << endl;
132
133  b_1.set_d(2,
134            4);
135
136  b_1.set_d(3,
137            7);
138
139  cout << "b_1 after updated by (3,7) /" << endl;
140  cout << b_1 << endl;
141  cout << endl;
142
143  b_1 = b_0;
144
145  cout << "b_1 after b_1=b_0 /" << endl;
146  cout << b_1 << endl;
147  cout << endl;
148
149  cout << "b_0 after b_1=b_0 /" << endl;
150  cout << b_0 << endl;
151  cout << endl;
152
153}