Yurttas/PL/OOL/Cplusplus/F/05/10/00/R.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2007
 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   : December 1, 2007.
11   author : Salih Yurttas.
12
13   R.cpp
14*/
15
16
17#include "N.h"
18
19using namespace N;
20
21template<class T>
22R<T>::
23R() : P<T>() {
24}
25
26template<class T>
27R<T>::
28R(const R<T>& o) {
29  P<T>::a = o.a;
30}
31
32template<class T>
33R<T>&
34R<T>::
35operator=(const R<T>& o) {
36  if(this==&o) return *this;
37
38  P<T>::a = o.a;
39
40  return *this;
41}
42
43template<class T>
44T
45R<T>::
46get_a(const int i) const {
47  return P<T>::a.at(i);
48}
49
50template<class T>
51void
52R<T>::
53set_a(const int size,
54      const T value) {
55  P<T>::a.clear();
56  for(int i=0; i<size; ++i)
57    P<T>::a.push_back(value);
58}
59
60template<class T>
61ostream& operator<<(ostream& os,
62                    const R<T>& o) {
63  int n = o.P<T>::a.size();
64  for(int i=0; i<n; ++i)
65    os << o.P<T>::a.at(i) << endl;
66  os << endl;
67
68  return os;
69}