Yurttas/PL/OOL/Cplusplus/F/05/10/11/t.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2005
 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   : September 1, 2005.
11   author : Salih Yurttas.
12
13   t.cpp
14*/
15
16
17#include <iostream>
18
19using namespace std;
20
21#include "P.h"
22#include "Q.h"
23#include "R.h"
24
25template<class T>
26void t() {
27
28  P<T>* p_a = new R<T>;
29
30  p_a->output();
31
32  vector<T> v = p_a->get_a();
33
34  int n = v.size();
35  for(int i=0; i<n; ++i)
36    cout << v.at(i) << endl;
37  cout << endl;
38
39  n = 4;
40
41  for(int i=0; i<n; ++i)
42    v.push_back(i);
43
44  p_a->set_a(v);
45
46  v = p_a->get_a();
47
48  n = v.size();
49  for(int i=0; i<n; ++i)
50    cout << v.at(i) << endl;
51  cout << endl;
52
53  p_a->set_a(2,
54             6);
55
56  p_a->output();
57
58  p_a = new Q<T>;
59
60  p_a->output();
61
62  p_a->set_a(v);
63
64  p_a->set_a(1,
65             9);
66
67  p_a->output();
68
69  p_a = new P<T>;
70
71  p_a->output();
72
73  P<T>* p_b = new Q<T>;
74
75  p_b->output();
76
77  n = 2;
78
79  for(int i=0; i<n; ++i)
80    v.push_back(i);
81
82  p_a->set_a(v);
83
84  p_a->output();
85
86  *p_a = *p_b;
87
88  p_a->output();
89
90  Q<T>* q_a = new Q<T>;
91
92  q_a->output();
93
94  cout << q_a->get_b() << endl;
95
96}