Yurttas/PL/OOL/Cplusplus/F/02/07/02/04/n 04.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2000
 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, 2000.
11   author : Salih Yurttas.
12
13   n_04.cpp
14*/
15
16
17#include "NA.h"
18
19using namespace NA;
20
21#include "NB.h"
22
23using namespace NB;
24
25#include <iostream>
26
27using namespace std;
28
29int main(int argc, char* argv[]) {
30
31  NA::S s_0("Apple");
32
33  cout << "initial values after default construction-S() /" << endl;
34  cout << "s_0 : ";
35  cout << s_0.get_s() << endl;
36  cout << endl;
37
38  NA::S s_1("Orange");
39
40  cout << "initial values after default construction-S() /" << endl;
41  cout << "s_1 : ";
42  cout << s_1.get_s() << endl;
43  cout << endl;
44
45  s_1 = s_0; // C++ provides = as memberwise assignment(default)
46             // actually, bitwise copy of s_0.s to s_1.s
47
48  cout << "after s_1=s_0 /" << endl;
49  cout << "s_1 : ";
50  cout << s_1.get_s() << endl;
51  cout << endl;
52
53  cout << "after s_1=s_0 /" << endl;
54  cout << "s_0 : ";
55  cout << s_0.get_s() << endl;
56  cout << endl;
57
58  NB::S ss_0("Kiwi");
59
60  cout << "initial values after default construction-S() /" << endl;
61  cout << "ss_0 : ";
62  cout << ss_0.get_s() << endl;
63  cout << endl;
64
65  NB::S ss_1("Mango");
66
67  cout << "initial values after default construction-S() /" << endl;
68  cout << "ss_1 : ";
69  cout << ss_1.NB::S::get_s() << endl;
70  cout << endl;
71
72  ss_1 = ss_0; // C++ provides = as memberwise assignment(default)
73               // actually, bitwise copy of ss_0.s to ss_1.s
74
75  cout << "after ss_1=ss_0 /" << endl;
76  cout << "ss_1 : ";
77  cout << ss_1.get_s() << endl;
78  cout << endl;
79
80  cout << "after ss_1=ss_0 /" << endl;
81  cout << "ss_0 : ";
82  cout << ss_0.get_s() << endl;
83  cout << endl;
84
85}