Yurttas/PL/OOL/Cplusplus/F/03/01/02/00/C.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   C.cpp
14*/
15
16
17#include "C.h"
18
19C::
20C(const int a) {
21  d = new int[N];
22
23  for(int i=0; i<N; ++i)
24    d[i] = a;
25}
26
27C::
28C(const C& a) {
29  d = new int[N];
30
31  for(int i=0; i<N; ++i)
32    d[i] = a.d[i];
33}
34
35C&
36C::
37operator=(const C& a) {
38  if(this==&a) return *this;
39
40  for(int i=0; i<N; ++i)
41    d[i] = a.d[i];
42
43  return *this;
44}
45
46C::
47~C() {
48  delete [] d;
49}
50
51int*
52C::
53get_d() const {
54  return d;
55}
56
57void
58C::
59set_d(const int a) {
60  for(int i=0; i<N; ++i)
61    d[i] = a;
62}
63
64void
65C::
66set_d(const int a,
67      const int b) {
68  d[0] = a;
69  d[1] = b;
70}
71
72void
73C::
74set_d(const int* a) {
75  for(int i=0; i<N; ++i)
76    d[i] = a[i];
77}
78
79ostream& operator<<(ostream& os,
80                    const C& a) {
81  for(int i=0; i<N; ++i)
82    os << a.d[i] << endl;
83
84  os << endl;
85
86  return os;
87}