-
Notifications
You must be signed in to change notification settings - Fork 0
/
CopyConstructor.cpp
54 lines (54 loc) · 1.05 KB
/
CopyConstructor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//#include <iostream>
//using namespace std;
//class Parent{
// int i;
//public:
// Parent(int ii):i(ii){
// cout<<"Parent(int ii)\n";
// }
// Parent(const Parent&b):i(b.i){
// cout<<"Parent(const Parent&)\n";
// }
// Parent():i(0){cout<<"Parent()\n";}
// friend ostream & operator<<(ostream&os,const Parent&b)
// {
// return os<<"parent:"<<b.i<<endl;
// }
//
//
//};
//class Member{
// int i;
//public:
// /*Member(){}
// Member(int ii):i(ii){
// cout<<"Member(int ii)\n";
// }*/
// friend ostream &operator<<(ostream&os,const Member&m)
// {
// return os<<"Member:"<<m.i<<endl;
// }
//
//};
//class Child:public Parent
//{
// int i;
// Member m;
//public:
// Child(const Child& c):i(c.i){}
//Child(int ii):Parent(ii),i(ii){
// cout<<"Child(int ii)\n"<<endl;
//}
//friend ostream &operator<<(ostream&os,const Child&c)
//{
// return os<<(Parent&)c<<c.m<<"Child: "<<c.i<<endl;
//}
//};
//int main()
//{
// Child c(2);
// cout<<"Calling copy-constructor:"<<endl;
// Child c2=c;
// cout<<"values in c2: \n"<<c2;
//
//}