-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut34.cpp
53 lines (44 loc) · 785 Bytes
/
tut34.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
#include <iostream>
using namespace std;
void name()
{
cout << 'Author: Varun Gupta' << endl;
}
class Big
{
int a;
public:
Big()
{
a=10;
}
Big(int o1)
{
a=o1;
}
// Whenever there is no copy constructor is found compiler supplies its own constructor.
Big(Big &a1)
{
a=a1.a;
cout << "This is copy constructor !!!:" <<a << endl;
}
void show()
{
cout<<"The value is :"<<a<<endl;
}
};
int main()
{
Big b1,b2,b3(95),b5;
b1.show();
b2.show();
b3.show();
Big b4(b3);
b4.show(); //Copy constructor invoked
b5=b3;
b5.show(); //Copy constructor not invoked.
Big b12=b2;
b12.show();// Copy Constructor invoked.
name();
return 1;
}