1
00:00:02,690 --> 00:00:05,270
Hello everyone so welcome to this new session.

2
00:00:05,270 --> 00:00:09,860
So we've already discussed about object oriented programming but there are a few topics that are left.

3
00:00:10,280 --> 00:00:10,640
OK.

4
00:00:10,760 --> 00:00:13,660
So let's discuss them one by one.

5
00:00:13,730 --> 00:00:13,960
OK.

6
00:00:13,970 --> 00:00:19,510
So there are some concepts self hopes they are abstraction

7
00:00:23,080 --> 00:00:24,040
and get solution

8
00:00:28,040 --> 00:00:32,230
and that are dance and polymorphism polymorphism

9
00:00:35,720 --> 00:00:36,000
OK.

10
00:00:36,010 --> 00:00:40,160
So in this we do we will try to cover these two.

11
00:00:40,210 --> 00:00:40,830
Okay.

12
00:00:40,840 --> 00:00:42,670
So we will go at these two and this will do.

13
00:00:42,670 --> 00:00:47,830
And then in the next two videos we will try to cover inheritance and polymorphism.

14
00:00:48,010 --> 00:00:50,910
Okay so let's start with the ancap solution.

15
00:00:50,980 --> 00:00:55,420
Okay so let's start with these encapsulation.

16
00:00:55,530 --> 00:00:57,600
So what is the meaning of encapsulation

17
00:01:01,120 --> 00:01:03,510
so the meaning of an absolution is clubbing.

18
00:01:03,760 --> 00:01:04,800
We have two club things.

19
00:01:04,830 --> 00:01:05,100
Okay.

20
00:01:05,140 --> 00:01:06,470
So combining things.

21
00:01:06,520 --> 00:01:14,200
So what we're doing encapsulation is we really combine the data and the functions data members and the

22
00:01:14,380 --> 00:01:17,120
functions okay.

23
00:01:17,330 --> 00:01:25,500
So combining that with the members and the functions of an entity is what we call encapsulation okay.

24
00:01:25,590 --> 00:01:32,690
Combining leader the members and the functions of an entity is what we call ancap solution okay.

25
00:01:32,710 --> 00:01:35,680
So we can achieve encapsulation with the help of a class.

26
00:01:35,680 --> 00:01:35,910
Okay.

27
00:01:35,920 --> 00:01:37,980
So this is nothing but a class.

28
00:01:38,020 --> 00:01:41,040
So with the help of class we can achieve encapsulation.

29
00:01:41,080 --> 00:01:42,480
Let us take an example.

30
00:01:42,520 --> 00:01:49,550
So suppose I have a student class so industrial in the class let's say the duty members let's say the

31
00:01:49,550 --> 00:01:50,590
properties are.

32
00:01:51,080 --> 00:01:51,960
I have a name.

33
00:01:52,010 --> 00:01:59,520
Name of the student age let's say I address okay and similarly

34
00:02:02,870 --> 00:02:06,110
we have functions like certain number

35
00:02:09,510 --> 00:02:10,980
and change and dress

36
00:02:14,330 --> 00:02:14,900
okay.

37
00:02:15,040 --> 00:02:23,580
So these are the data members and these are the functions okay.

38
00:02:23,590 --> 00:02:30,600
So if you will combine the data members and the functions of an entity then it is called Encapsulation.

39
00:02:30,600 --> 00:02:36,330
So here we are combining the data members and functions into a single unit.

40
00:02:36,340 --> 00:02:37,770
Okay so this is a single unit

41
00:02:40,960 --> 00:02:43,540
with the help of glass with the help of glass.

42
00:02:43,600 --> 00:02:52,000
We can achieve our goal of encapsulation Okay so now we will color abstraction.

43
00:02:52,040 --> 00:02:52,300
Okay.

44
00:02:52,310 --> 00:02:57,690
So let's see what is abstraction.

45
00:02:57,900 --> 00:03:06,090
So what is the meaning of abstraction so the meaning of abstraction is to hide hiding what we can see

46
00:03:06,090 --> 00:03:06,800
hide.

47
00:03:06,810 --> 00:03:07,080
Okay.

48
00:03:07,100 --> 00:03:10,510
So what we will do we will hide the unnecessary details.

49
00:03:10,620 --> 00:03:11,080
Okay.

50
00:03:11,160 --> 00:03:14,490
Hiding the tools which are not important from the outside world.

51
00:03:15,500 --> 00:03:16,030
Okay.

52
00:03:16,050 --> 00:03:19,720
Hide the details which are not relevant to the outside world.

53
00:03:19,880 --> 00:03:22,100
For example we have a TV.

54
00:03:22,130 --> 00:03:22,910
Okay.

55
00:03:23,300 --> 00:03:26,740
So for example let us talk about television.

56
00:03:26,870 --> 00:03:31,170
So how we will operate television we will operate TV using the remote.

57
00:03:31,190 --> 00:03:31,480
Okay.

58
00:03:31,490 --> 00:03:38,490
So with the help of remote we can perform many operations such as on and off changing channels.

59
00:03:38,600 --> 00:03:40,880
Increase volume or decrease volume.

60
00:03:40,910 --> 00:03:41,180
Okay.

61
00:03:41,200 --> 00:03:45,120
But we do not know what happens internally when you press a button.

62
00:03:45,290 --> 00:03:45,540
Okay.

63
00:03:45,560 --> 00:03:49,060
We do not know what happens and then we leave whenever we press a button.

64
00:03:49,100 --> 00:03:49,490
Okay.

65
00:03:49,580 --> 00:03:52,250
So there is no need for us to know that.

66
00:03:52,400 --> 00:03:52,600
Okay.

67
00:03:52,610 --> 00:03:56,330
It is not important for us to know what happens when we press a button.

68
00:03:56,330 --> 00:04:02,480
So there is no need for us to know what happens internally and let's have one more example let's take

69
00:04:02,480 --> 00:04:03,500
the example of a car.

70
00:04:04,070 --> 00:04:09,990
Okay so we all know how to drive a car but we do not know how a car works.

71
00:04:10,070 --> 00:04:13,730
Okay we do not need to know how a car works to drive a car.

72
00:04:14,680 --> 00:04:14,960
Okay.

73
00:04:14,960 --> 00:04:20,810
So we are hiding the properties we are hiding how a car works from the user Okay use it will simply

74
00:04:20,810 --> 00:04:22,630
come and drive the car.

75
00:04:22,880 --> 00:04:25,370
There is no need for us to know how a car works.

76
00:04:26,060 --> 00:04:26,780
Okay.

77
00:04:26,780 --> 00:04:28,820
So these are the real world example.

78
00:04:28,820 --> 00:04:33,290
Now let's seen called So what we are doing good.

79
00:04:33,750 --> 00:04:38,190
So we all know we have studied about smart yesterday about sorting.

80
00:04:38,190 --> 00:04:39,990
So we have AI and built heart function.

81
00:04:39,990 --> 00:04:42,150
So what does symbol chart function will do.

82
00:04:42,150 --> 00:04:45,680
It will take it as input and it will sort the idea accordingly.

83
00:04:45,690 --> 00:04:46,130
Okay.

84
00:04:46,320 --> 00:04:50,850
So we have this inbuilt heart function we have this inbuilt heart function.

85
00:04:50,850 --> 00:04:52,350
So internally how it works.

86
00:04:52,380 --> 00:04:53,070
I don't care.

87
00:04:54,240 --> 00:04:54,700
Okay.

88
00:04:54,780 --> 00:04:59,310
So what we will do but use every Lou it will simply call the function sort.

89
00:04:59,700 --> 00:05:05,940
And it will give daddy and that I will get started now use it doesn't care how internally this sort

90
00:05:05,940 --> 00:05:11,590
function work although we yesterday studied about heart function but there is no need for us to like.

91
00:05:11,610 --> 00:05:14,610
There is no need for us to study how a starting works.

92
00:05:14,640 --> 00:05:16,350
We can likely use this function.

93
00:05:16,440 --> 00:05:19,380
Okay so internally how it works I don't care.

94
00:05:19,380 --> 00:05:29,800
Similarly we have something called SDL it stands for standard template library.

95
00:05:29,960 --> 00:05:32,510
So what happens is we have many of your structures

96
00:05:35,840 --> 00:05:40,360
so the example of the district just like stacks.

97
00:05:40,500 --> 00:05:45,800
Q hash map and so on.

98
00:05:45,800 --> 00:05:48,910
Okay so we have many data centers inside there still.

99
00:05:48,950 --> 00:05:51,680
These data suggest I already implemented.

100
00:05:51,780 --> 00:05:58,010
Okay so many of your district chairs are already implemented in standard amplitude in standard template

101
00:05:58,010 --> 00:05:58,520
library.

102
00:05:58,880 --> 00:06:06,260
So what we will do for example if I want to create a stack I will simply write create a stack often

103
00:06:06,260 --> 00:06:12,050
Deja and the name of the stack is as OK if I want to push element inside the stack.

104
00:06:12,080 --> 00:06:16,430
I will write as not push if I want to pop element.

105
00:06:16,550 --> 00:06:25,310
I will write as dark pop Okay so I don't care how internally it works okay.

106
00:06:25,320 --> 00:06:30,160
I don't care how I intend to lead the stack is implemented in the standard template library.

107
00:06:30,180 --> 00:06:34,920
I will just use these lines and I will get a stack okay.

108
00:06:34,950 --> 00:06:37,870
So we are hiding all these things from the use it.

109
00:06:37,930 --> 00:06:39,650
So there it is called abstraction.

110
00:06:39,820 --> 00:06:43,870
So how can we achieve abstraction so we can achieve abstraction using glass.

111
00:06:44,290 --> 00:06:50,240
Okay so let's see how so let's say we have a student class inside the student class.

112
00:06:50,260 --> 00:07:02,900
I have name rule number address so we have a class student and they say this within a class we have

113
00:07:02,900 --> 00:07:06,190
three properties name number and address.

114
00:07:06,200 --> 00:07:11,090
Now what I want to do is I want to hide the rule number from the outside world.

115
00:07:11,120 --> 00:07:14,770
Okay I want to hide this property from the outside world.

116
00:07:14,900 --> 00:07:21,330
So how we will do it in the class simply we will make this property a private property.

117
00:07:21,340 --> 00:07:21,620
Okay.

118
00:07:21,640 --> 00:07:26,950
So making the properties as private properties this is called abstraction.

119
00:07:26,950 --> 00:07:31,480
Whenever we make a property private this will not be accessible to the outside world.

120
00:07:31,990 --> 00:07:32,270
Okay.

121
00:07:32,320 --> 00:07:33,250
So this thing.

122
00:07:33,250 --> 00:07:38,280
So making the properties if you make properties private then we call it abstraction.

123
00:07:38,290 --> 00:07:39,880
We are hiding the property.

124
00:07:39,880 --> 00:07:40,130
Okay.

125
00:07:40,150 --> 00:07:43,810
So we can achieve abstraction using the class.

126
00:07:44,050 --> 00:07:49,330
If someone wants to access the raw lumber it has to call a public function of this class.

127
00:07:49,480 --> 00:07:51,880
So we will create a public function of this class.

128
00:07:52,000 --> 00:07:56,140
And if user wants to access the raw number you can access the rule number with the help of the public

129
00:07:56,140 --> 00:07:56,650
functions.

130
00:07:57,220 --> 00:07:57,670
Okay.

131
00:07:57,760 --> 00:08:01,690
But this property is directly not visible to the outside world.

132
00:08:01,990 --> 00:08:02,250
Okay.

133
00:08:02,250 --> 00:08:03,990
So we are hiding this property.

134
00:08:04,180 --> 00:08:08,050
So we have discussed what is abstraction and how we can achieve it.

135
00:08:08,050 --> 00:08:13,450
Now the question is why we want to hide details okay why we want to do abstractions.

136
00:08:13,480 --> 00:08:16,520
So there are two main reasons for doing abstractions.

137
00:08:16,660 --> 00:08:30,710
And the first reason is so the first major reason is ablation or changes so what happens is if we change

138
00:08:30,710 --> 00:08:34,460
our own code then and use the code should not be affected.

139
00:08:35,140 --> 00:08:35,540
Okay.

140
00:08:35,630 --> 00:08:40,360
So if we change our own code then user code should not be affected.

141
00:08:40,370 --> 00:08:47,340
So suppose I have a start function the art function will take as input and it will sort the area.

142
00:08:47,750 --> 00:08:56,500
Okay so let's assume initially art function internally uses bubbles art Okay let's assume we know this

143
00:08:56,500 --> 00:09:01,710
is not right but let us assume initially this thought function uses bubbles art.

144
00:09:01,810 --> 00:09:04,080
So how will user call this function.

145
00:09:04,120 --> 00:09:07,380
It will write a user will call the function in this minute sort.

146
00:09:07,390 --> 00:09:08,710
And it will give the idea.

147
00:09:09,790 --> 00:09:14,260
So now after some time we realize that bubbles art is not an efficient sorting out your name it is and

148
00:09:14,260 --> 00:09:15,070
square.

149
00:09:15,070 --> 00:09:21,130
So with changes we change internally how does art how this art function work which changes the bubbles

150
00:09:21,130 --> 00:09:23,100
out in two quick art.

151
00:09:23,110 --> 00:09:28,190
Earlier we used to use bubbles art but now we are using quick art.

152
00:09:28,210 --> 00:09:30,220
Inside this art function internally.

153
00:09:30,230 --> 00:09:35,180
Okay so if I am using quick sword now so we'll use a code will be affected.

154
00:09:35,200 --> 00:09:36,730
So the output is no.

155
00:09:36,730 --> 00:09:39,280
So the answer is no use the code will not break.

156
00:09:39,550 --> 00:09:40,100
Okay.

157
00:09:40,180 --> 00:09:46,450
If user has allowed some program inside the program if you use it is using this art function and if

158
00:09:46,450 --> 00:09:50,920
I change the internal workings of this art function then user call will not be affected.

159
00:09:50,920 --> 00:09:52,720
User code will not big.

160
00:09:52,720 --> 00:09:55,540
Okay so this is the first reason why we do abstraction.

161
00:09:56,350 --> 00:09:56,640
Okay.

162
00:09:56,650 --> 00:10:00,280
So if we change our own code then use a code should not be affected.

163
00:10:00,280 --> 00:10:08,460
Now the second main reason is to avoid errors second major reason for doing a restriction is to avoid

164
00:10:08,460 --> 00:10:09,270
errors.

165
00:10:09,300 --> 00:10:11,880
So how can we avoid this using extinction.

166
00:10:11,880 --> 00:10:16,230
So suppose this art function is a public function.

167
00:10:16,550 --> 00:10:18,500
So if this is a public function what will happen.

168
00:10:18,500 --> 00:10:20,520
Anyone can come and change it.

169
00:10:21,070 --> 00:10:21,500
Okay.

170
00:10:21,620 --> 00:10:27,200
And your numbers can come and it can change the internal properties of this art function internal logic

171
00:10:27,200 --> 00:10:28,490
of this art function.

172
00:10:28,490 --> 00:10:28,720
Okay.

173
00:10:28,730 --> 00:10:29,890
So what will happen.

174
00:10:29,920 --> 00:10:32,890
User can introduce errors in our code.

175
00:10:32,990 --> 00:10:33,250
Okay.

176
00:10:33,280 --> 00:10:35,000
But you don't want those errors.

177
00:10:35,000 --> 00:10:39,570
So what do we do we will make this art function private okay.

178
00:10:39,650 --> 00:10:44,760
So what we will do we will hide the crucial properties since we will hide the crucial properties.

179
00:10:44,810 --> 00:10:50,360
User cannot come and change those properties so user cannot introduce those errors in our code.

180
00:10:50,360 --> 00:10:52,220
Okay so we should always do.

181
00:10:52,230 --> 00:10:55,450
Abstraction Okay so this is all about abstraction.

182
00:10:55,520 --> 00:10:58,650
And next to we a deal we will discuss about inheritance.

183
00:10:58,700 --> 00:10:59,660
Okay thank you.
