-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path12.cpp
More file actions
43 lines (39 loc) · 787 Bytes
/
12.cpp
File metadata and controls
43 lines (39 loc) · 787 Bytes
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
//WAP to copy value of 2 parameters from one constructor to another using copy constructor.
#include<iostream>
#include<string>
using namespace std;
class students
{
public:
int a,b;
students() //Default Constructor
{
a=0;
b=0;
}
students(int x,int y) //1st Constructor
{
a=x;
b=y;
}
students(students & object) //Copy Constructor
{
cout<< "\nCopy Constructor Called";
a=object.a;
b=object.b;
}
void displaydata()
{
cout<< "\nA: "<< a <<"\nB: "<< b <<"\n";
}
};
int main()
{
students one;
students two(2,3);
//one.displaydata();
two.displaydata();
students s1(two);
s1.displaydata();
return 0;
}