Yurttas/PL/OOL/Cplusplus/F/04/02/01/00/p 00.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 p_00.cpp
14*/
15
16
17#include <iostream>
18
19using namespace std;
20
21#include "P.h"
22
23int main(int argc, char* argv[]) {
24
25// static testing
26 P p1;
27
28 cout << "p1 initial values after default construction-P() /" << endl;
29 cout << p1 << endl;
30
31 cout << "p1 accessors after mutators /" << endl;
32 p1.set_i1(2);
33 cout << p1.get_i1() << endl;
34 cout << endl;
35
36 P p2(9);
37
38 cout << "p2 initial values after P(9) /" << endl;
39 cout << p2 << endl;
40
41 P p3(p2);
42
43 cout << "p3 initial values after copy construction p3(p2) /" << endl;
44 cout << p3 << endl;
45 cout << "p2 values after copy construction p3(p2) /" << endl;
46 cout << p2 << endl;
47
48 cout << "p3 accessors after mutators /" << endl;
49 p3.set_i1(1);
50 cout << p3.get_i1() << endl;
51 cout << endl;
52
53 cout << "p1 /" << endl;
54 cout << p1 << endl;
55 cout << "p2 /" << endl;
56 cout << p2 << endl;
57
58 p2 = p1;
59
60 cout << "p2 values after p2=p1 /" << endl;
61 cout << p2 << endl;
62 cout << "p1 values after p2=p1 /" << endl;
63 cout << p1 << endl;
64
65// dynamic testing
66
67 P * p4 = new P;
68
69 cout << "p4 initial values after default construction-P() /" << endl;
70 cout << p4 << endl;
71
72 cout << "p4 accessors after mutators /" << endl;
73 p4->set_i1(2);
74 cout << p4->get_i1() << endl;
75 cout << endl;
76
77 delete p4;
78
79 p4 = new P(9);
80
81 cout << "p4 initial values after P(9) /" << endl;
82 cout << *p4 << endl;
83
84 P * p5 = new P(*p4);
85
86 cout << "p5 initial values after copy construction *p5(*p4) /" << endl;
87 cout << *p5 << endl;
88 cout << "p4 values after copy construction *p5(*p4) /" << endl;
89 cout << *p4 << endl;
90
91 cout << "p5 accessors after mutators /" << endl;
92 p5->set_i1(1);
93 cout << p5->get_i1() << endl;
94 cout << endl;
95
96 cout << "p4 /" << endl;
97 cout << *p4 << endl;
98 cout << "p5 /" << endl;
99 cout << *p5 << endl;
100
101 *p4 = *p5;
102
103 cout << "p4 values after *p4=*p5 /" << endl;
104 cout << *p4 << endl;
105 cout << "p5 values after *p4=*p5 /" << endl;
106 cout << *p5 << endl;
107
108 P p6(*p4);
109
110 cout << "p6 initial values after copy construction p6(*p4) /" << endl;
111 cout << p6 << endl;
112 cout << "p4 values after copy construction p6(*p4) /" << endl;
113 cout << *p4 << endl;
114
115}