Yurttas/PL/OOL/Cplusplus/F/03/01/02/00/d 00.cpp

 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   d_00.cpp
14*/
15
16
17#include <iostream>
18
19using namespace std;
20
21#include "D.h"
22
23int main(int argc, char* argv[]) {
24
25  D d_0;
26
27  cout << "initial values after construction-D(int) /" << endl;
28  cout << d_0 << endl;
29  cout << endl;
30
31  int n = d_0.get_s();
32
33  int* aa = new int[n];
34
35  aa = d_0.get_d();
36
37  cout << "aa after d_0.get_d() /" << endl;
38  for(int i=0; i<n; ++i)
39    cout << aa[i] << endl;
40
41  cout << endl;
42
43  d_0.set_d(9);
44
45  cout << "d_0 after updated by (9) /" << endl;
46  cout << d_0 << endl;
47  cout << endl;
48
49  D d_1(d_0);
50
51  cout << "initial values after construction-D(D&) /" << endl;
52  cout << d_1 << endl;
53  cout << endl;
54
55  d_1.set_d(3,7);
56
57  cout << "d_1 after updated by (3,7) /" << endl;
58  cout << d_1 << endl;
59  cout << endl;
60
61  n = d_1.get_s();
62
63  aa = new int[n];
64
65  for(int i=0; i<n; ++i)
66    aa[i] = 5;
67
68  d_1.set_d(aa);
69
70  cout << "d_1 after updated by (aa) /" << endl;
71  cout << d_1 << endl;
72  cout << endl;
73
74  d_1 = d_0;
75
76  cout << "d_1 after d_1=d_0 /" << endl;
77  cout << d_1 << endl;
78  cout << endl;
79
80  cout << "d_0 after d_1=d_0 /" << endl;
81  cout << d_0 << endl;
82  cout << endl;
83
84  D d_2(8,7);
85
86  cout << "initial values after construction-D(int) /" << endl;
87  cout << d_2 << endl;
88  cout << endl;
89
90}