Yurttas/PL/OOL/Cplusplus/F/03/02/02/00/01/V.cpp
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 V.cpp
14*/
15
16
17#include "V.h"
18
19V::
20V(const int n) : size(n),
21 data(new int[n]) {
22 for(int i=0; i<size; ++i)
23 data[i] = 1;
24}
25
26V::
27V(const V& a) : size(a.size),
28 data(new int[size]) {
29 for(int i=0; i<size; ++i)
30 data[i] = a.data[i];
31}
32
33V::
34~V() {
35 delete [] data;
36}
37
38V&
39V::
40operator=(const V& a) {
41 if(this==&a) return *this;
42
43 delete [] data;
44
45 size = a.size;
46 data = new int[size];
47
48 for(int i=0; i<size; ++i)
49 data[i] = a.data[i];
50
51 return *this;
52}
53
54ostream&
55operator<<(ostream& os,
56 const V& a) {
57 int n = a.size;
58
59 for(int i=0; i<n; ++i)
60 os << a.data[i] << endl;
61 os << endl;
62
63 return os;
64}