1
00:00:02,260 --> 00:00:03,240
Hello everyone.

2
00:00:03,250 --> 00:00:08,770
In the last few videos we learned about constructor and this session we will try a few more interesting

3
00:00:08,770 --> 00:00:09,460
examples

4
00:00:13,540 --> 00:00:15,720
so this is our class student.

5
00:00:16,030 --> 00:00:23,340
So the student class has one private property each and then we have our destructor our default constructor

6
00:00:23,500 --> 00:00:26,150
and then we have to promote based constructor.

7
00:00:26,260 --> 00:00:30,920
The first one takes a rule number as input and the second parameter is constructor take Agent.

8
00:00:30,940 --> 00:00:32,150
Rule number as input.

9
00:00:32,290 --> 00:00:38,610
And then we have a public field a public property rule number and then a public function display good

10
00:00:38,650 --> 00:00:41,350
data function and stage function.

11
00:00:41,350 --> 00:00:45,640
OK so now let us create some object

12
00:00:49,170 --> 00:00:55,470
student S-1 now which constructed data you call it will required default constructor.

13
00:00:55,470 --> 00:00:57,930
So constructor one called

14
00:01:04,130 --> 00:01:10,830
so the default constructors construct seven then parameters constructor to which takes on the role number

15
00:01:10,830 --> 00:01:12,740
is in Porter's constructor to.

16
00:01:13,050 --> 00:01:16,480
And the constructor which takes a general number is constructor three.

17
00:01:16,990 --> 00:01:17,570
Okay.

18
00:01:17,600 --> 00:01:20,240
So in this case constructor one will be called

19
00:01:24,450 --> 00:01:25,980
Student 2.

20
00:01:26,520 --> 00:01:29,280
And let us give rule number as input.

21
00:01:29,280 --> 00:01:32,820
Now which construct page will call it will call the constructor to

22
00:01:37,140 --> 00:01:43,680
so constructor to called Story entry.

23
00:01:43,680 --> 00:01:45,900
Now this time I will give a general number.

24
00:01:46,650 --> 00:01:51,000
So 10 hundred no constructor table be called here

25
00:01:54,660 --> 00:01:57,690
construct Petrie card

26
00:02:01,740 --> 00:02:06,100
student for and as 3 as input.

27
00:02:06,100 --> 00:02:09,250
STUDENT 3 As input now which constructively recoiled.

28
00:02:10,300 --> 00:02:12,160
So copy construct level recall here

29
00:02:15,130 --> 00:02:16,720
copy constructor call.

30
00:02:16,750 --> 00:02:20,070
Now this copy constructors and world copy constructor.

31
00:02:20,140 --> 00:02:30,480
Okay now what if I do still rent when it goes to rental now which constructively call ahead.

32
00:02:30,620 --> 00:02:35,690
So no constructor will recall here but assign this to I'd already cleared in the memory.

33
00:02:35,690 --> 00:02:41,020
So copy assignment operator will be called copy assignment operator.

34
00:02:41,610 --> 00:02:48,400
Okay copy assignment operator called copy of a large recall here.

35
00:02:48,400 --> 00:02:48,760
Why.

36
00:02:48,760 --> 00:02:55,230
Because both S1 and S2 are already created the already existing memory.

37
00:02:55,240 --> 00:02:57,350
Now let's take one more example.

38
00:02:57,520 --> 00:03:03,070
Student s 5 equals S3.

39
00:03:03,310 --> 00:03:05,820
Now which constructor will be called here.

40
00:03:05,950 --> 00:03:06,760
Copy constructor

41
00:03:11,310 --> 00:03:13,530
so copy constructor call here.

42
00:03:13,540 --> 00:03:14,140
Now let's see

43
00:03:19,860 --> 00:03:27,280
see what is the meaning of the slain we are creating a new object and then we are copying the values

44
00:03:27,280 --> 00:03:32,620
of S3 into S5 so we can break this line into two lines.

45
00:03:32,620 --> 00:03:43,270
First we are creating an object and then we are copying the value of student 3 OBJECTION TO STUDENT

46
00:03:43,270 --> 00:03:44,290
5.

47
00:03:44,330 --> 00:03:50,100
Okay so in this line default constructor will be called and add this line.

48
00:03:50,500 --> 00:03:52,920
Copy assignment operator will be called okay.

49
00:03:52,930 --> 00:04:00,250
Copy assignment operator will be called but if I see Add this line if I see this line then copy constructor

50
00:04:00,280 --> 00:04:01,280
is being called.

51
00:04:01,340 --> 00:04:01,660
Why.

52
00:04:02,530 --> 00:04:04,780
Because what compiler ever do.

53
00:04:04,810 --> 00:04:06,340
So these are two lines.

54
00:04:06,340 --> 00:04:10,100
Okay so word compiler Lou would come by level Lou.

55
00:04:10,120 --> 00:04:19,130
It will optimize it will convert these two lines into one single line compiler will optimize.

56
00:04:19,150 --> 00:04:28,530
So optimize internally come by level interpreted compiler will interpret this line into one single line

57
00:04:28,560 --> 00:04:35,650
which is student s 5 as 3 okay.

58
00:04:35,660 --> 00:04:45,300
So compiler will interpret these two lines in this fashion so if you write student s faith equals S3

59
00:04:46,830 --> 00:04:51,950
S3 this is same as to render S5 vector S3.

60
00:04:51,990 --> 00:04:58,730
Okay so that's why copy constructor is called copy construct based.

61
00:04:58,810 --> 00:04:59,590
Here.

62
00:04:59,700 --> 00:05:04,400
Okay so this was the special case student that's equals S3.

63
00:05:04,440 --> 00:05:07,460
This is a special case and you must remember it.

64
00:05:07,470 --> 00:05:13,380
Okay so this time copy constructor will be called here and not copy assignment operator okay.

65
00:05:15,120 --> 00:05:15,510
Thank you.
