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

From ZCubes Wiki
Revision as of 22:49, 6 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="cpp" line start="1" enclose="div">/* Copyright(C) 2005 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. Perm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 "P.cpp"
18#include "Q.cpp"
19#include "R.cpp"
20
21template<class T>
22void t() {
23
24  P<T>* p_a = new R<T>;
25
26  p_a->output();
27
28  vector<T> v = p_a->get_a();
29
30  int n = v.size();
31  for(int i=0; i<n; ++i)
32    cout << v.at(i) << endl;
33  cout << endl;
34
35  n = 4;
36
37  for(int i=0; i<n; ++i)
38    v.push_back(i);
39
40  p_a->set_a(v);
41
42  v = p_a->get_a();
43
44  n = v.size();
45  for(int i=0; i<n; ++i)
46    cout << v.at(i) << endl;
47  cout << endl;
48
49  p_a->set_a(2,
50             6);
51
52  p_a->output();
53
54  p_a = new Q<T>;
55
56  p_a->output();
57
58  p_a->set_a(v);
59
60  p_a->set_a(1,
61             9);
62
63  p_a->output();
64
65  p_a = new P<T>;
66
67  p_a->output();
68
69  P<T>* p_b = new Q<T>;
70
71  p_b->output();
72
73  n = 2;
74
75  for(int i=0; i<n; ++i)
76    v.push_back(i);
77
78  p_a->set_a(v);
79
80  p_a->output();
81
82  *p_a = *p_b;
83
84  p_a->output();
85
86  Q<T>* q_a = new Q<T>;
87
88  q_a->output();
89
90  cout << q_a->get_b() << endl;
91
92}