1
00:00:02,630 --> 00:00:03,260
Hello everyone.

2
00:00:03,260 --> 00:00:07,670
So in the last session we learned about operator overloading and the overloaded manual but it does for

3
00:00:07,670 --> 00:00:09,210
our fiction glass.

4
00:00:09,230 --> 00:00:12,220
Now we want to create that last dynamic Gary.

5
00:00:12,320 --> 00:00:19,700
So in this session what we will do we will create a class dynamic Gary and in that dynamic class.

6
00:00:20,210 --> 00:00:21,830
But other functionalities.

7
00:00:21,830 --> 00:00:26,070
So we want first of all we will take R and D ready.

8
00:00:26,320 --> 00:00:31,020
And the function that we want is user can add as much number of elements as he wants.

9
00:00:31,140 --> 00:00:31,410
Okay.

10
00:00:31,420 --> 00:00:35,650
So the problem with the normal arrays we have to tell the size in front.

11
00:00:35,650 --> 00:00:35,960
Okay.

12
00:00:35,980 --> 00:00:39,970
We have to tell the size before then we declare our area of size five.

13
00:00:39,970 --> 00:00:41,120
The size will be five.

14
00:00:41,230 --> 00:00:43,600
The size can be 10 or the size will be N.

15
00:00:43,690 --> 00:00:43,930
Okay.

16
00:00:43,930 --> 00:00:48,830
We cannot extend the size on for example if we have an area of size 10.

17
00:00:48,880 --> 00:00:53,050
So if we have an area of size 10 so this is index 9.

18
00:00:53,060 --> 00:00:54,300
We have an idea of size 10.

19
00:00:54,380 --> 00:01:00,470
So we cannot insert the eleventh element user cannot insert the eleventh element of the size of barest.

20
00:01:00,490 --> 00:01:03,900
And so we will solve this problem by building our own class.

21
00:01:03,910 --> 00:01:04,160
Okay.

22
00:01:04,170 --> 00:01:05,100
So what we will do.

23
00:01:05,100 --> 00:01:06,550
How can we solve this problem.

24
00:01:06,550 --> 00:01:09,760
So our logic is internally what we will do.

25
00:01:10,270 --> 00:01:12,730
So internally we will maintain energy.

26
00:01:13,030 --> 00:01:16,380
Let's say the size of that is initially five.

27
00:01:16,510 --> 00:01:21,310
So zero one two three and four.

28
00:01:21,320 --> 00:01:24,490
So let's say that initially the size of that is five.

29
00:01:24,500 --> 00:01:31,400
So what we will do as soon as the user will enter the sixth element as soon as the user will try to

30
00:01:31,400 --> 00:01:38,740
enter the sixth element what we will do we will make a new every so this area will be double.

31
00:01:39,170 --> 00:01:40,840
So the size was initially five.

32
00:01:40,840 --> 00:01:44,370
Now we will create an array of size 10 and we will copy the data.

33
00:01:44,380 --> 00:01:48,640
For example it was 10 20 30 40 and 50.

34
00:01:48,640 --> 00:01:50,770
So we will create a new area.

35
00:01:50,970 --> 00:01:52,690
Will you copy that data.

36
00:01:52,730 --> 00:02:00,170
So 10 20 30 40 and 50 and now the user can insert the sixth element here.

37
00:02:01,160 --> 00:02:05,230
Okay so use I will insert the sixth element here and now this Eddie.

38
00:02:05,540 --> 00:02:07,090
This will point towards this.

39
00:02:07,430 --> 00:02:08,120
Okay.

40
00:02:08,180 --> 00:02:13,640
And we will D allocate the memory as soon as our array gets filled up.

41
00:02:13,670 --> 00:02:20,260
What we will do we will create a new every copy day content from the already the allocated the already.

42
00:02:20,270 --> 00:02:23,030
And now that it will point towards this.

43
00:02:23,060 --> 00:02:28,180
Similarly if this at every Goldfield if the size if all the 10 elements are in that it will do look

44
00:02:28,180 --> 00:02:35,370
we will create an area of size 20 we will copy the older 10 data fields or 10 data and then the new

45
00:02:35,440 --> 00:02:38,730
it will point towards this area of size 20.

46
00:02:38,730 --> 00:02:39,020
Okay.

47
00:02:39,050 --> 00:02:41,290
So in this way we can solve this problem.

48
00:02:41,330 --> 00:02:41,560
Okay.

49
00:02:41,570 --> 00:02:45,140
So what will be our data members.

50
00:02:45,250 --> 00:02:46,520
So what do your data members.

51
00:02:46,600 --> 00:02:50,000
First of all we will need our dynamic Gary.

52
00:02:50,030 --> 00:02:51,230
Okay.

53
00:02:51,230 --> 00:02:52,750
So in Star data.

54
00:02:52,910 --> 00:02:58,210
So this is our in beta I didn't need your pointer so we initialized decided dynamically in the constructor.

55
00:02:58,280 --> 00:03:00,110
So in the constructor what we will do

56
00:03:03,010 --> 00:03:07,930
in the constructor we will initialize this dynamic very let's say initially I am taking this I used

57
00:03:07,930 --> 00:03:10,390
to be five so new in five.

58
00:03:10,810 --> 00:03:12,780
Okay so this is how we will initialize that.

59
00:03:13,120 --> 00:03:13,960
So what will happen

60
00:03:16,700 --> 00:03:21,120
this is data and it is of size 5 inside the constructor.

61
00:03:21,140 --> 00:03:21,460
Okay.

62
00:03:21,980 --> 00:03:24,220
So what we will do now we will want a function.

63
00:03:24,230 --> 00:03:27,360
So we will create a function add element.

64
00:03:27,410 --> 00:03:29,270
So what this add element function will do.

65
00:03:29,270 --> 00:03:33,380
It will take a element which is to be inserted inside the area.

66
00:03:33,650 --> 00:03:35,320
So where the element will be inserted.

67
00:03:35,390 --> 00:03:41,240
So that element will be inserted at the uh it will be inserted at the next index available for example

68
00:03:41,240 --> 00:03:44,460
let's see this at a condensed 10 and 20.

69
00:03:44,480 --> 00:03:47,060
So that element will be inserted here.

70
00:03:47,060 --> 00:03:47,540
Okay.

71
00:03:47,630 --> 00:03:51,370
So let's say the element is 30 and next element will be inserted here.

72
00:03:51,380 --> 00:03:53,630
Similarly the next element will be inserted here.

73
00:03:53,660 --> 00:03:53,870
Okay.

74
00:03:53,870 --> 00:03:54,350
So next.

75
00:03:54,470 --> 00:03:57,730
So the element will be inserted at the next index available.

76
00:03:57,890 --> 00:03:59,600
So inside this function what we will do.

77
00:03:59,600 --> 00:04:00,540
We will.

78
00:04:00,560 --> 00:04:06,650
So that is the name of the array data and element if it is the first element.

79
00:04:06,650 --> 00:04:08,190
So it will be zero.

80
00:04:08,270 --> 00:04:09,350
If it is the second element.

81
00:04:09,350 --> 00:04:10,230
Then it will be one.

82
00:04:10,730 --> 00:04:11,690
And so on.

83
00:04:11,690 --> 00:04:12,150
Okay.

84
00:04:12,230 --> 00:04:15,480
So how can we know that at which next we have to insert.

85
00:04:16,180 --> 00:04:16,590
Okay.

86
00:04:16,670 --> 00:04:19,760
So how we can decide that we can next we have to insert the element.

87
00:04:19,760 --> 00:04:25,040
So for maintaining this and next we will create one more data member with the name next to Nick's

88
00:04:27,790 --> 00:04:32,740
so I will have one more data member and next to Nick's.

89
00:04:32,770 --> 00:04:36,030
So next 16 points to that index which is empty.

90
00:04:36,190 --> 00:04:37,540
And we can insert it idea idea.

91
00:04:37,780 --> 00:04:40,510
Okay so initially next to index will be zero.

92
00:04:40,630 --> 00:04:43,840
We will insert our first element at index 0.

93
00:04:43,900 --> 00:04:44,150
Okay.

94
00:04:44,170 --> 00:04:53,500
So what we will do we will write data off next index is element and then we will do next the next plus

95
00:04:53,500 --> 00:04:54,590
plus.

96
00:04:54,610 --> 00:04:58,240
Okay so this is how it will work again.

97
00:04:58,290 --> 00:05:04,820
And now we will also take one more data member which is the size of the area okay.

98
00:05:04,820 --> 00:05:07,390
So these are that really the members that we will take.

99
00:05:08,320 --> 00:05:08,620
Okay.

100
00:05:08,630 --> 00:05:10,700
Let us take an example to understand it better

101
00:05:16,280 --> 00:05:24,210
so let us take an example so let's say initially my duty is of size 5.

102
00:05:24,240 --> 00:05:31,270
And initially the arrays empty by empty I mean it contains a guide which value Okay so 0 1 2 3 and 4

103
00:05:31,510 --> 00:05:32,620
maximum Dex will be.

104
00:05:33,160 --> 00:05:36,650
And I am having an extra Nyx and size.

105
00:05:36,670 --> 00:05:39,720
So these are the theory the members initially next and next will be zero.

106
00:05:39,820 --> 00:05:41,830
And the size is five.

107
00:05:41,890 --> 00:05:42,550
Okay.

108
00:05:42,550 --> 00:05:45,060
We will call the function add 10.

109
00:05:45,070 --> 00:05:45,340
Okay.

110
00:05:45,340 --> 00:05:50,560
So 10 will be inserted here and the Nixon next becomes 1 then we will call add 20.

111
00:05:50,650 --> 00:05:55,320
So 20 will be inserted next or next to insert 30 add today.

112
00:05:55,330 --> 00:05:56,980
So 30 will be inserted.

113
00:05:56,980 --> 00:05:59,300
Now then next becomes three add 40.

114
00:05:59,350 --> 00:06:01,220
So this is add function.

115
00:06:01,600 --> 00:06:05,090
Now add 40 so far they will be inserted at index 3.

116
00:06:05,260 --> 00:06:07,150
And now the index becomes four.

117
00:06:07,510 --> 00:06:12,300
So now add 50 so 50 will be inserted.

118
00:06:12,690 --> 00:06:15,750
And now what will happen if I tried to insert one more element.

119
00:06:15,810 --> 00:06:18,460
So if I write add 60.

120
00:06:18,600 --> 00:06:20,650
Sorry this is this it next becomes 5.

121
00:06:20,700 --> 00:06:22,240
So when we write add 60.

122
00:06:22,410 --> 00:06:24,680
So there is not space to insert the element.

123
00:06:24,870 --> 00:06:28,650
And what happened is next to next become equal to the size.

124
00:06:28,650 --> 00:06:32,520
So as soon as the next makes in the size both are equal but they have to do.

125
00:06:32,520 --> 00:06:39,300
We will create our area of size double so this area was of size 4.

126
00:06:39,330 --> 00:06:49,040
Now we will create an area of size 10 and we will copy the 5 fields the 5 data fields and so then 20

127
00:06:49,340 --> 00:06:53,970
30 40 and 50 and now the 60 will be inserted here.

128
00:06:54,040 --> 00:06:54,350
Okay.

129
00:06:54,350 --> 00:06:59,860
And so the next to next will become 6 and the size will get a better 2 10.

130
00:06:59,870 --> 00:07:00,300
Okay.

131
00:07:00,410 --> 00:07:07,820
So what we have to remember we have to remember if the next to next becomes equal to size what we have

132
00:07:07,820 --> 00:07:09,530
to do we have to double Larry.

133
00:07:09,620 --> 00:07:13,310
We have to create a new area of double size and then copy the old content.

134
00:07:13,680 --> 00:07:14,190
Okay.

135
00:07:14,210 --> 00:07:19,360
So now let's see in called we will understand with the help of God no.

136
00:07:19,560 --> 00:07:21,840
So the class biomimicry.

137
00:07:21,960 --> 00:07:25,810
So what I will do I will keep all my properties private.

138
00:07:26,040 --> 00:07:35,370
So let's create our data let's create our Eddie with the name data and we will keep next index.

139
00:07:35,660 --> 00:07:39,590
Next and next is the index at which our element will be inserted.

140
00:07:39,600 --> 00:07:48,770
Initially it will be zero and capacity and capacity is the total size of the area total size of the

141
00:07:49,730 --> 00:07:50,030
area.

142
00:07:50,750 --> 00:07:54,320
Okay so now let's create a constructor so public

143
00:07:59,760 --> 00:08:03,570
so in the name of the constructors we all know it the same as the name of the class.

144
00:08:03,580 --> 00:08:08,250
So dynamic today and now we really initialize our data members.

145
00:08:09,910 --> 00:08:13,640
So first initialize our dynamic array.

146
00:08:13,680 --> 00:08:15,890
So the is its own digit area.

147
00:08:15,900 --> 00:08:19,360
And let's say initially I am keeping the size of data to be 5.

148
00:08:20,010 --> 00:08:26,040
Okay so next to index it will be 0 because the first element will be inserted to 0.

149
00:08:26,040 --> 00:08:29,880
And I'm keeping the capacity that would have that it will be 5.

150
00:08:30,390 --> 00:08:30,960
Okay.

151
00:08:30,960 --> 00:08:33,030
Now let us create a function and function.

152
00:08:33,030 --> 00:08:38,420
So void and it will take our element as input which is to be inserted.

153
00:08:38,550 --> 00:08:42,940
So element we have to insert this element inside our area.

154
00:08:44,540 --> 00:08:49,150
So we have to handle the case when the next size.

155
00:08:49,150 --> 00:08:53,260
So even the next index becomes equal to the capacity of the area.

156
00:08:54,760 --> 00:08:59,310
Now if this is not the case then the code is very simple.

157
00:08:59,320 --> 00:09:07,280
We just have to go to the next or next and then put the element okay.

158
00:09:07,450 --> 00:09:10,800
And what we have to do next or next plus plus.

159
00:09:10,810 --> 00:09:11,350
Okay.

160
00:09:11,350 --> 00:09:12,470
So now let's see.

161
00:09:12,580 --> 00:09:18,220
Now let's see how can we handle this case when the next train makes it becomes equal to the capacity.

162
00:09:18,220 --> 00:09:18,630
Okay.

163
00:09:18,700 --> 00:09:19,810
So how can we handle this.

164
00:09:19,810 --> 00:09:20,560
What we have to do

165
00:09:25,670 --> 00:09:29,830
okay so now this is the case when everybody gets food.

166
00:09:29,930 --> 00:09:35,920
So next size soda next or next contains five capacity contains five.

167
00:09:35,930 --> 00:09:42,460
And this is our very so five elements have already been inserted in this area.

168
00:09:42,470 --> 00:09:47,420
And 10 20 30 40 and 50.

169
00:09:48,080 --> 00:09:48,350
Okay.

170
00:09:48,360 --> 00:09:52,520
So this is my dear diary okay.

171
00:09:52,560 --> 00:09:58,240
So now what I want to add I want to add a new element at 60.

172
00:09:58,290 --> 00:10:01,470
Okay so the next X equals 2 the capacity.

173
00:10:01,500 --> 00:10:07,130
So what I have to do I will create a new area of double size.

174
00:10:07,200 --> 00:10:16,700
So this is a new area of double size so zero one two three four.

175
00:10:16,790 --> 00:10:19,630
And it will go up to nine in next nine.

176
00:10:19,730 --> 00:10:20,310
Okay.

177
00:10:20,360 --> 00:10:27,240
So after creating the new idea let's name it new data so this is new layer to what we have to do.

178
00:10:27,360 --> 00:10:30,890
We will copy the old content you have to copy these old content.

179
00:10:30,900 --> 00:10:35,920
So 10 20 30 40 and 50.

180
00:10:35,940 --> 00:10:38,670
So after copying the old content what we will do.

181
00:10:38,670 --> 00:10:40,840
So we will look at this memory.

182
00:10:40,890 --> 00:10:44,760
So since it's a dynamic memory we have to process this memory.

183
00:10:44,790 --> 00:10:46,670
This area is created in the heat memory.

184
00:10:46,710 --> 00:10:47,690
We have to delete it.

185
00:10:47,700 --> 00:10:48,030
Okay.

186
00:10:48,030 --> 00:10:49,490
So it is our responsibility.

187
00:10:49,530 --> 00:10:55,440
So where delete this memory and this data will now points towards this area.

188
00:10:55,560 --> 00:10:58,530
And now we will add the element here.

189
00:10:58,530 --> 00:11:05,800
So 60 will be added here and the value of capacity is now 10 and the next index will become 6.

190
00:11:06,350 --> 00:11:07,010
Okay.

191
00:11:07,020 --> 00:11:08,460
So in this weird playbook.

192
00:11:09,210 --> 00:11:17,710
Okay so let's write the code for this what we have to do we have to create a new array of double size.

193
00:11:17,710 --> 00:11:21,070
So US neighbour New data the size will be double.

194
00:11:21,370 --> 00:11:27,600
So new end to times of the current capacity okay.

195
00:11:27,640 --> 00:11:32,470
So after creating the new idea what we have to do copy the old content.

196
00:11:32,470 --> 00:11:39,390
So for copying the old content so I listen capacity I plus plus

197
00:11:43,720 --> 00:11:50,620
so new data if I is your Delphi so the second mark is also done.

198
00:11:50,680 --> 00:11:57,670
We have copied the what we have to do we have to delete the old lady Barry which was initially of size

199
00:11:57,670 --> 00:11:58,380
five.

200
00:11:58,510 --> 00:12:02,220
Okay so we have to delete that diary because it's our dynamic memory.

201
00:12:02,350 --> 00:12:02,620
Okay.

202
00:12:02,650 --> 00:12:03,490
We have to delete it.

203
00:12:03,490 --> 00:12:04,960
It's a heap memory.

204
00:12:04,960 --> 00:12:13,910
So we have to delete the world data and now that all data it will point towards the new data the newly

205
00:12:13,910 --> 00:12:20,480
created Eddie and we have to double our capacity so capacity will also get better so capacity equals

206
00:12:20,510 --> 00:12:23,900
capacity multiplied by two.

207
00:12:23,900 --> 00:12:25,460
Okay so what will happen

208
00:12:29,700 --> 00:12:31,350
so we are deleting the data.

209
00:12:31,380 --> 00:12:33,210
So what will happen if we not glad that you're done.

210
00:12:33,210 --> 00:12:35,380
It is called memory leak.

211
00:12:35,600 --> 00:12:37,360
I think I've already told you before.

212
00:12:37,370 --> 00:12:38,150
What does memory leak.

213
00:12:38,180 --> 00:12:46,630
So now Daredevil is pointing towards an eddy which was of size five and then we created a new data so

214
00:12:46,630 --> 00:12:51,300
this new data this was area of size 10.

215
00:12:51,400 --> 00:12:57,190
So what I did I deleted this memory and then the new data points toward the data the old data point

216
00:12:57,190 --> 00:12:58,430
towards the new data.

217
00:12:58,480 --> 00:12:58,750
Okay.

218
00:12:58,780 --> 00:13:03,580
So if you will or delete this memory then this phenomena is called memory leak.

219
00:13:04,180 --> 00:13:05,190
Okay.

220
00:13:05,460 --> 00:13:06,520
This is quite a memory leak.

221
00:13:07,240 --> 00:13:10,960
Okay so one more thing by the data is pointing towards this new data.

222
00:13:11,780 --> 00:13:12,290
Why.

223
00:13:12,310 --> 00:13:19,180
Because if you see here the new data the scope of new data it is inside the F block only.

224
00:13:19,180 --> 00:13:19,410
Okay.

225
00:13:19,420 --> 00:13:25,020
So as soon as you reach line number 22 the new data is not like it will not exist anymore.

226
00:13:25,020 --> 00:13:29,170
So we have to like point so that data will point towards the newly created data.

227
00:13:29,170 --> 00:13:30,610
You look at it to Daddy.

228
00:13:30,760 --> 00:13:32,020
Okay.

229
00:13:32,200 --> 00:13:33,130
So what will happen.

230
00:13:33,130 --> 00:13:34,980
The capacity will become twice.

231
00:13:35,080 --> 00:13:39,790
Now we will come out of the if condition and then we will insert the element.

232
00:13:39,790 --> 00:13:47,060
So if we want to insert element 16 so element will be inserted and we will do next to nix plus plus.

233
00:13:47,240 --> 00:13:49,010
Okay so this was very simple.

234
00:13:49,010 --> 00:13:50,730
Now let us create one more function.

235
00:13:51,110 --> 00:13:54,020
So this function is get the element function.

236
00:13:54,050 --> 00:13:54,490
Okay.

237
00:13:54,590 --> 00:13:55,750
So get element function.

238
00:13:55,790 --> 00:14:02,270
But it will take it will take I indexes input so usable so user will ask us what is that data present

239
00:14:02,330 --> 00:14:04,370
at index 2 at next 3.

240
00:14:04,370 --> 00:14:04,610
Okay.

241
00:14:04,610 --> 00:14:06,880
So we are creating a get function.

242
00:14:07,070 --> 00:14:08,870
So inside the good function.

243
00:14:08,900 --> 00:14:12,370
So if the index is valued by value nobody means.

244
00:14:12,440 --> 00:14:13,580
So if the index is good.

245
00:14:13,580 --> 00:14:14,570
Then it goes to zero.

246
00:14:14,630 --> 00:14:16,130
Obviously index cannot be negative.

247
00:14:16,520 --> 00:14:20,090
So if the index is valid index is not negative.

248
00:14:20,330 --> 00:14:28,040
And also the index is less than the next index next NICS means the number of elem inside the 80.

249
00:14:28,060 --> 00:14:32,720
So if the index is less than an extra NICs and then only we can return the data.

250
00:14:32,850 --> 00:14:36,970
Okay so they done data if I now.

251
00:14:37,090 --> 00:14:38,380
Else what do we do.

252
00:14:39,970 --> 00:14:40,980
So in the else part.

253
00:14:40,990 --> 00:14:44,150
That means the index is not valid.

254
00:14:44,270 --> 00:14:44,610
Okay.

255
00:14:44,630 --> 00:14:45,790
So we will return.

256
00:14:45,880 --> 00:14:49,610
We will are done our default value let's say our default values minus 1.

257
00:14:49,610 --> 00:14:50,090
Okay.

258
00:14:50,180 --> 00:14:54,110
So if the index is not valid let's say the index is minus 2.

259
00:14:54,380 --> 00:14:56,360
So minus 2 like it means nothing.

260
00:14:56,390 --> 00:14:56,720
Okay.

261
00:14:57,020 --> 00:14:58,480
So we will return minus 1.

262
00:14:58,520 --> 00:14:59,930
And similarly what is next.

263
00:14:59,930 --> 00:15:04,560
Next next next is the number of elements that has been inserted inside the array.

264
00:15:04,670 --> 00:15:07,370
So let's say then next year next we lose 5.

265
00:15:07,370 --> 00:15:09,100
And I is like say 10.

266
00:15:09,170 --> 00:15:11,340
So obviously we will return minus 1.

267
00:15:11,360 --> 00:15:11,630
Okay.

268
00:15:11,630 --> 00:15:19,840
So what I am saying here is so let's say I created our object of for Dynamic arrays or dynamic at a

269
00:15:20,150 --> 00:15:22,520
given I'm creating an object.

270
00:15:22,630 --> 00:15:30,450
So next the index is 0 initially capacities 5 initially and the data contains the address 7 entered

271
00:15:31,000 --> 00:15:34,050
and this is our array of size 5.

272
00:15:34,240 --> 00:15:36,820
So that does have the first element is 700.

273
00:15:37,390 --> 00:15:37,700
Okay.

274
00:15:37,750 --> 00:15:43,950
So 0 1 2 index 3 and index food.

275
00:15:44,790 --> 00:15:52,330
Okay now let us try to add the elements Okay so add a hundred and ten so ten will be inserted next to

276
00:15:52,330 --> 00:15:56,250
index becomes one at twenty so twenty inserted next.

277
00:15:56,250 --> 00:15:58,410
Next becomes to add 30.

278
00:15:58,410 --> 00:16:07,010
So to be inserted next to next becomes three add 40 so 40 inserted next year next becomes food added

279
00:16:07,010 --> 00:16:09,600
50 so 50 inserted.

280
00:16:09,600 --> 00:16:11,570
Next year next becomes five.

281
00:16:11,640 --> 00:16:14,660
Okay so now if we will add 60.

282
00:16:14,670 --> 00:16:20,180
So what happened is an extra index and the capacity they become equal again.

283
00:16:20,280 --> 00:16:21,290
Very simple process.

284
00:16:21,300 --> 00:16:23,520
Create a new every.

285
00:16:23,740 --> 00:16:26,190
Now the size of this area will be the oil.

286
00:16:26,200 --> 00:16:27,410
It will be 10.

287
00:16:27,640 --> 00:16:32,650
So the capacity gourd separated to 10 copy the oil content.

288
00:16:32,740 --> 00:16:38,150
So 10 20 30 40 50.

289
00:16:38,200 --> 00:16:42,650
So next and next will become 6 and the element 60 will be inserted.

290
00:16:42,910 --> 00:16:45,520
And let's say the address of this new year times eight under.

291
00:16:45,520 --> 00:16:50,740
So this is new data that does of new data is 800.

292
00:16:50,740 --> 00:16:54,240
So this data will get to be two to 800.

293
00:16:54,280 --> 00:16:54,710
Okay.

294
00:16:54,820 --> 00:16:56,650
Now let's see the good function.

295
00:16:56,650 --> 00:17:04,540
So inside the good function if I write get 3 so index 3 is a positive index and also the index 3 is

296
00:17:04,540 --> 00:17:07,660
less than 6 which is an extra index.

297
00:17:07,690 --> 00:17:09,970
So that means index 3 is valid.

298
00:17:09,970 --> 00:17:11,410
Okay so next 3 is valid.

299
00:17:11,410 --> 00:17:19,140
If I write get 6 this is not valid because because the value of next index is 6.

300
00:17:19,150 --> 00:17:23,910
That means that next element which is to be inserted it will get inserted at index 6.

301
00:17:24,160 --> 00:17:25,270
It is empty.

302
00:17:25,540 --> 00:17:26,400
So this is wrong.

303
00:17:26,530 --> 00:17:28,360
That's why we write this condition.

304
00:17:28,360 --> 00:17:36,010
Similarly if I write get 50 so obviously this is also wrong because we only have currently 6 elements

305
00:17:37,970 --> 00:17:38,340
okay.

306
00:17:38,710 --> 00:17:42,910
So this condition it is very important to write this condition okay.

307
00:17:44,260 --> 00:17:50,390
Now let us create one more function which is the variation of this add function.

308
00:17:50,400 --> 00:17:55,170
Okay so what we will do now this time we want to add an element.

309
00:17:55,250 --> 00:18:03,860
So void Ed but we want to add an element but this time user will give us the index at which he wants

310
00:18:03,860 --> 00:18:04,630
to add element.

311
00:18:04,670 --> 00:18:05,570
So in.

312
00:18:06,020 --> 00:18:13,110
So the meaning of this line is insert the element at index i.

313
00:18:13,510 --> 00:18:17,410
Okay so we have to insert the element and at the next day let us take an example.

314
00:18:18,250 --> 00:18:19,690
So let's say my dear diaries

315
00:18:22,310 --> 00:18:34,280
let's say it is 10 20 30 and so my arrays of size 5 0 1 2 3 and 4.

316
00:18:34,340 --> 00:18:39,250
Okay next indexes 3 and the capacities 5.

317
00:18:39,280 --> 00:18:39,560
Okay.

318
00:18:39,580 --> 00:18:41,880
Next nexus 3 capacity is 5.

319
00:18:41,890 --> 00:18:43,380
Now let's see this function.

320
00:18:43,390 --> 00:18:49,820
So the element is let's say a hundred and user wants to insert at the 2.

321
00:18:49,990 --> 00:18:51,280
So we will go to index 2.

322
00:18:51,310 --> 00:18:54,730
It is today we will make it hundred no problem.

323
00:18:54,730 --> 00:18:55,020
Okay.

324
00:18:55,030 --> 00:18:57,260
This is right index to element hundred.

325
00:18:57,280 --> 00:19:01,390
It is right now let's say that element is 200.

326
00:19:01,610 --> 00:19:06,700
And the indexes 3 so I use 3 which is equal to the next index.

327
00:19:06,710 --> 00:19:10,750
So what will do we will insert 200 here.

328
00:19:10,850 --> 00:19:11,500
No problem.

329
00:19:12,380 --> 00:19:19,900
Okay now let's say the element is 300 and let's say the indexes then.

330
00:19:20,390 --> 00:19:23,960
Okay so index 10 so index ten does not exist.

331
00:19:24,560 --> 00:19:33,630
Okay so if you compare so index 10 is greater than next to index so if this is the condition that means

332
00:19:33,690 --> 00:19:34,740
this is wrong.

333
00:19:34,740 --> 00:19:36,830
Okay so this is right.

334
00:19:36,900 --> 00:19:44,220
If this is what is the condition so I is less than next to nix and this is the condition when I equals

335
00:19:44,220 --> 00:19:45,040
2 next.

336
00:19:45,050 --> 00:19:45,710
Next.

337
00:19:45,720 --> 00:19:48,860
So these two conditions are valid and this is not valid.

338
00:19:48,870 --> 00:19:55,130
Okay so in this case we will not do anything we will not insert the element we will simply return okay.

339
00:19:55,150 --> 00:19:56,590
In this case it will seem better done

340
00:20:01,070 --> 00:20:08,500
so the first case when the element to be inserted at index i.e. is less than an extra next then it is

341
00:20:08,500 --> 00:20:08,980
very easy.

342
00:20:08,980 --> 00:20:11,010
We just have to override the value.

343
00:20:11,320 --> 00:20:18,140
Okay we will we just have to override the current value element.

344
00:20:18,260 --> 00:20:26,020
Now the second case was when the index at which the element to be inserted is it goes to the next index.

345
00:20:26,030 --> 00:20:31,460
So in this case what we have to do we have to handle everything like if the edit gets filled.

346
00:20:31,460 --> 00:20:36,500
We have to double the size copied all that a copy the content of the whole area and everything but for

347
00:20:36,500 --> 00:20:39,050
that to be able to dictate the function add.

348
00:20:39,140 --> 00:20:41,810
Okay so we will simply call the add function.

349
00:20:42,470 --> 00:20:43,030
Okay.

350
00:20:43,250 --> 00:20:49,040
So for this case when the element to be inserted is next to index.

351
00:20:49,040 --> 00:20:50,720
So we simply will call this function.

352
00:20:50,720 --> 00:20:55,960
And so this ad function will get called and this at a function will handle everything.

353
00:20:56,300 --> 00:20:56,740
Okay.

354
00:20:59,050 --> 00:21:07,070
And it is when will come to us when the main index eye is good then adding extra day.

355
00:21:07,070 --> 00:21:09,240
So in this case we will not insert the element.

356
00:21:09,250 --> 00:21:10,180
We will simply return.

357
00:21:10,420 --> 00:21:10,890
Okay.

358
00:21:10,990 --> 00:21:16,360
You can write a print statement that is the index is not valid or something like that or you can throw

359
00:21:16,360 --> 00:21:16,630
at it.

360
00:21:16,960 --> 00:21:19,210
Okay so you can do whatever you want.

361
00:21:19,240 --> 00:21:22,020
I am simply returning okay.

362
00:21:22,260 --> 00:21:25,430
So now let us also create a print function.

363
00:21:25,430 --> 00:21:25,720
Okay.

364
00:21:25,770 --> 00:21:31,550
So that we can print out any so let us create a function wide print.

365
00:21:32,220 --> 00:21:38,110
So what this print function will do it will it will print the elements of the area.

366
00:21:38,130 --> 00:21:38,390
Okay.

367
00:21:38,400 --> 00:21:43,980
So for we just have to I read nothing much so forint equals zero.

368
00:21:43,980 --> 00:21:56,360
I list an extra index I bless plus and we will print the value of the the content of the edit okay.

369
00:22:01,530 --> 00:22:02,630
Okay so that's all.

370
00:22:02,670 --> 00:22:06,170
So one thing here is I'll list the next index.

371
00:22:06,210 --> 00:22:11,850
This is right or I should write I list in capacity so I should write I'll list an next year next why

372
00:22:11,850 --> 00:22:16,940
next next because next index means these main number of elements has been inserted inside the area.

373
00:22:17,280 --> 00:22:17,820
Okay.

374
00:22:17,820 --> 00:22:19,860
Capacity music total size of the area.

375
00:22:19,860 --> 00:22:22,470
So we have to write next to index.

376
00:22:22,500 --> 00:22:28,000
Okay so now let us try to create some object and let's see how our code is working.

377
00:22:28,170 --> 00:22:35,460
So we have included the file dynamic candidate CBB and the name of this file is dynamic at a used start

378
00:22:35,460 --> 00:22:35,890
CPB.

379
00:22:35,920 --> 00:22:44,290
Okay so let us create our object so dynamic at a Deven and let us add some elements.

380
00:22:44,440 --> 00:22:45,370
So then

381
00:22:56,330 --> 00:22:58,080
so we are inserting six elements.

382
00:22:58,100 --> 00:22:58,420
Okay

383
00:23:01,350 --> 00:23:03,840
so add this line what will happen.

384
00:23:03,840 --> 00:23:10,830
Default constructively called default constructor that we have written that we have created so that

385
00:23:10,830 --> 00:23:11,800
constructively because.

386
00:23:11,840 --> 00:23:14,580
So the size or dynamic array was 5.

387
00:23:14,640 --> 00:23:16,650
But here I am inserting 6 elements.

388
00:23:16,870 --> 00:23:22,030
Okay so what will happen the size of that is 10 the size of the arrays then.

389
00:23:22,070 --> 00:23:23,960
And because the new idea will be created.

390
00:23:23,960 --> 00:23:27,350
Okay so now let us call the function print

391
00:23:30,330 --> 00:23:32,220
also let us create a function.

392
00:23:32,220 --> 00:23:37,380
Get capacity so that I can prove it to you that the size of that is 10.

393
00:23:37,410 --> 00:23:37,690
Okay.

394
00:23:37,710 --> 00:23:39,870
So get capacity function

395
00:23:46,400 --> 00:23:51,880
so let's say I have a function return I will be in danger and the name of the function is.

396
00:23:51,980 --> 00:23:53,970
Capacity.

397
00:23:54,060 --> 00:24:01,250
So what it will do it will retain the capacity of the dynamic at a certain capacity.

398
00:24:01,290 --> 00:24:08,400
OK so the size of the idea was initially five and then we we insert six elements.

399
00:24:08,410 --> 00:24:09,800
So the size will be 10.

400
00:24:10,200 --> 00:24:10,730
Okay.

401
00:24:10,840 --> 00:24:12,680
So here we can see the size.

402
00:24:12,760 --> 00:24:13,990
The size will be 10.

403
00:24:14,910 --> 00:24:15,540
Okay.

404
00:24:15,670 --> 00:24:16,510
So now let's.

405
00:24:16,510 --> 00:24:19,510
In this file okay.

406
00:24:19,520 --> 00:24:23,420
So what we have to do what is the problem

407
00:24:27,350 --> 00:24:28,100
Sammy.

408
00:24:28,450 --> 00:24:28,660
Oh

409
00:24:34,050 --> 00:24:34,740
and also

410
00:24:53,690 --> 00:24:54,010
okay.

411
00:24:54,020 --> 00:24:56,470
So okay we have not printed.

412
00:24:56,630 --> 00:24:58,240
So let's print the capacity.

413
00:24:58,280 --> 00:24:59,030
So see old

414
00:25:02,250 --> 00:25:05,830
deviantart to get capacity and line

415
00:25:11,920 --> 00:25:15,760
so the content of that is 10 20 30 40 50 and 60.

416
00:25:15,820 --> 00:25:18,520
And the size of the arrays then.

417
00:25:18,520 --> 00:25:19,060
Okay.

418
00:25:19,180 --> 00:25:22,270
So our code is working fine.

419
00:25:22,270 --> 00:25:26,980
Okay so now let us create another object

420
00:25:30,490 --> 00:25:34,390
so dynamic Gary V2 given.

421
00:25:34,420 --> 00:25:36,320
So what will happen at this line.

422
00:25:36,550 --> 00:25:39,020
We all know copy concept will be called.

423
00:25:39,340 --> 00:25:41,520
Since we have not written the copy constructor.

424
00:25:41,530 --> 00:25:45,090
So what will happen and will copy constructor will get called.

425
00:25:45,100 --> 00:25:49,870
And now let us change the value of what I'm doing.

426
00:25:50,420 --> 00:25:53,740
I am inserting the element hundred at index 0.

427
00:25:53,800 --> 00:25:59,030
Okay so let me see first so first I am taking element and then index.

428
00:25:59,050 --> 00:26:06,360
So I have to give element first and then I am giving the index.

429
00:26:06,390 --> 00:26:14,590
Okay so now let's print Deven and we will print due to.

430
00:26:14,690 --> 00:26:15,500
So what will happen

431
00:26:20,630 --> 00:26:25,430
so at this language will happen copy constructor will be called and we will not copy constructor what

432
00:26:25,430 --> 00:26:27,410
it does it create shallow copy.

433
00:26:27,970 --> 00:26:28,240
Okay.

434
00:26:28,250 --> 00:26:29,420
So what should be our output.

435
00:26:29,420 --> 00:26:30,250
Let's see first

436
00:26:32,960 --> 00:26:38,360
so let's say when we created when the default construct is called What is the scenario.

437
00:26:38,540 --> 00:26:40,700
Let's say we have inserted only four elements.

438
00:26:40,700 --> 00:26:44,290
Okay there are only four elements we have inserted four elements.

439
00:26:44,390 --> 00:26:54,700
So Deven data let's say it contains the address 700 and the next index it will be we have inserted four

440
00:26:54,700 --> 00:27:01,470
elements so next and next week before and its capacity is five okay.

441
00:27:01,530 --> 00:27:04,800
And at this line we are creating a new object.

442
00:27:04,800 --> 00:27:09,230
So do you do so due to data will also contain 700.

443
00:27:09,240 --> 00:27:12,510
It will copy all the properties of the given object.

444
00:27:12,510 --> 00:27:14,770
So the next index also forward.

445
00:27:14,850 --> 00:27:17,660
And the capacity also five.

446
00:27:17,670 --> 00:27:18,000
Okay.

447
00:27:18,030 --> 00:27:20,170
So we can see here.

448
00:27:20,220 --> 00:27:22,170
700 and 700.

449
00:27:22,170 --> 00:27:23,460
So what copy constructor will do.

450
00:27:23,460 --> 00:27:26,650
It creates a shallow copy or shallow copy will be created.

451
00:27:26,670 --> 00:27:33,440
And what I am doing here is I am changing the first value of the I'm changing the zero element to hundred.

452
00:27:33,480 --> 00:27:33,770
Okay.

453
00:27:33,810 --> 00:27:39,210
So the idea was 10 20 30 40 50 and 60.

454
00:27:39,240 --> 00:27:44,720
So this was the event every and I am changing the first index.

455
00:27:45,140 --> 00:27:52,610
Now doing that it will become this under 20 30 40 50 60 and we are printing the 102 but we will see

456
00:27:52,850 --> 00:27:58,950
when I print due to arguably be hundred at zero the index hundred will be printed.

457
00:27:59,030 --> 00:27:59,600
Okay.

458
00:27:59,630 --> 00:28:00,080
Why.

459
00:28:00,110 --> 00:28:03,110
Because we all know copy gastric procreate shallow copy.

460
00:28:03,110 --> 00:28:03,680
So let's see

461
00:28:07,410 --> 00:28:15,180
okay so we can see here with changes with changes in the dynamic added even by the changes are also

462
00:28:15,180 --> 00:28:17,230
done for dynamic error do you do.

463
00:28:17,430 --> 00:28:17,930
Okay.

464
00:28:17,940 --> 00:28:22,940
And the reason is we all know by the course copy gastric decorates shallow copy.

465
00:28:23,310 --> 00:28:27,680
Okay so one more thing can we use copy assignment operator.

466
00:28:27,690 --> 00:28:30,090
Okay so let's try to use copy assignment operator

467
00:28:33,200 --> 00:28:36,680
so I am creating dynamic 83

468
00:28:40,790 --> 00:28:50,070
so default consecutively record and then I am using copy assignment operator so add this line copy assignment

469
00:28:51,980 --> 00:29:01,780
operator called Okay and then I will do the changes for Deven and then I am printing the event you do

470
00:29:01,800 --> 00:29:10,260
and let's say we are also printing these three Okay so I am printing Deven data and data.

471
00:29:10,640 --> 00:29:17,090
So at this line our default constructively we call okay our default constructively recalled and then

472
00:29:17,120 --> 00:29:22,880
I am copying the values of Deven and do the three or add this line also I like call our default constructor

473
00:29:22,880 --> 00:29:23,510
will be called.

474
00:29:23,630 --> 00:29:26,120
So I am copying the values of the into D3.

475
00:29:26,120 --> 00:29:30,830
So do you think after doing changes in Deven detail will not be affected.

476
00:29:30,920 --> 00:29:34,660
So the point is copy assignment operator also create slow copy.

477
00:29:34,820 --> 00:29:35,090
Okay.

478
00:29:35,090 --> 00:29:36,670
It will also carry a cello copy.

479
00:29:36,920 --> 00:29:41,570
So given due to the tree the oil will contain everything will get changed.

480
00:29:41,570 --> 00:29:47,870
Okay I am doing changes in Deven so that changes will get reflected in due to because cello copy and

481
00:29:47,870 --> 00:29:53,630
the changes will also get affected in the tree because again copies and not operator again creates cello

482
00:29:53,630 --> 00:29:54,140
copy.

483
00:29:54,140 --> 00:29:54,920
Okay so let's see

484
00:29:58,140 --> 00:30:04,970
so we can see here is the changes individually but the changes got reflected for the 23.

485
00:30:04,980 --> 00:30:09,420
Okay so here it is mandatory for us to create deep copy.

486
00:30:09,420 --> 00:30:09,650
Okay.

487
00:30:09,660 --> 00:30:18,220
So how to create deep copy so we have to create a copy constructor first.

488
00:30:18,340 --> 00:30:24,640
So if w what I am doing here is I am creating my own copy constructor Okay I am creating my own copy.

489
00:30:24,880 --> 00:30:34,860
So this index is very familiar so dynamic Gary and what it will we will take our dynamic Gary constraint

490
00:30:34,890 --> 00:30:40,810
offense so constant reference by constant defense because you do not want to call copy against a better

491
00:30:40,810 --> 00:30:42,320
ways in finite loop.

492
00:30:42,320 --> 00:30:43,160
I hope you remember

493
00:30:46,000 --> 00:30:47,510
so I have to copy everything.

494
00:30:47,630 --> 00:30:49,490
So let us first copy the next index

495
00:30:52,210 --> 00:30:52,640
did

496
00:30:55,440 --> 00:31:03,470
next to nix so this error capacity is needed capacity

497
00:31:07,910 --> 00:31:14,040
and this ATL data is the DOD data.

498
00:31:14,060 --> 00:31:15,440
Okay so this line

499
00:31:18,630 --> 00:31:20,220
this is shallow copy.

500
00:31:20,220 --> 00:31:23,980
So this is the code which is that are done inside the inbuilt copy constructor.

501
00:31:24,720 --> 00:31:32,260
Okay so now we will create deep copy so I hope everyone remember what is the procedure for creating

502
00:31:32,260 --> 00:31:34,210
the deep copies of the procedure is very simple.

503
00:31:34,220 --> 00:31:36,880
Create the new every copy the world will lose.

504
00:31:36,880 --> 00:31:40,700
So we have to create a new area.

505
00:31:40,790 --> 00:31:45,290
So let's say new and so what of the size size will be the large capacity

506
00:31:48,100 --> 00:31:48,460
okay.

507
00:31:48,490 --> 00:31:51,760
Here we do not need to do plus one in case of string.

508
00:31:51,760 --> 00:31:54,870
We need to do placement because we want to copy the Democratic proposal.

509
00:31:55,000 --> 00:31:56,840
So here no need to do plus one.

510
00:31:57,040 --> 00:32:00,930
And now we have to copy the content.

511
00:32:00,970 --> 00:32:03,130
So in case of string we have a function string copy.

512
00:32:03,130 --> 00:32:06,310
But in case of an integer that we do not have such function.

513
00:32:06,310 --> 00:32:09,280
So we have to copy the old content of dairy.

514
00:32:09,610 --> 00:32:11,800
So the DOT I should write.

515
00:32:11,800 --> 00:32:14,260
Do you draw an extra next or do you not capacity.

516
00:32:14,260 --> 00:32:21,210
So the answer is next 16 y an extra X because next makes me use these main number of elements has been

517
00:32:21,210 --> 00:32:22,860
inserted inside the area.

518
00:32:23,220 --> 00:32:26,310
And what we have to do we have to copy the content.

519
00:32:26,310 --> 00:32:37,910
So this raw data if I is the dart data off i okay So everything seems fine.

520
00:32:37,970 --> 00:32:39,740
Let me check this.

521
00:32:40,430 --> 00:32:42,400
Okay so according to me everything is fine.

522
00:32:43,280 --> 00:32:43,530
Okay.

523
00:32:43,540 --> 00:32:44,180
One more thing.

524
00:32:44,180 --> 00:32:45,090
This is optional.

525
00:32:45,200 --> 00:32:45,710
Okay.

526
00:32:45,810 --> 00:32:50,670
Writing this is optional because uh do you draw next 16 and next and next.

527
00:32:50,960 --> 00:32:55,250
We can easily separate out okay and constant offense I hope you know.

528
00:32:55,760 --> 00:32:57,130
Okay so everything seems fine.

529
00:32:57,140 --> 00:33:00,720
Later on this file and now we will run this fine.

530
00:33:00,750 --> 00:33:00,980
Okay.

531
00:33:00,990 --> 00:33:03,210
So what will happen when we run this file.

532
00:33:03,210 --> 00:33:06,660
If we do changes in Deven so do two will remain unaffected.

533
00:33:06,780 --> 00:33:07,640
Okay so let's see.

534
00:33:11,170 --> 00:33:11,740
Okay.

535
00:33:11,890 --> 00:33:16,210
So handed and the value of the two is pen only.

536
00:33:16,300 --> 00:33:16,770
Okay.

537
00:33:16,870 --> 00:33:18,430
So the code is working.

538
00:33:18,520 --> 00:33:20,950
And now let us fix this problem also.

539
00:33:20,950 --> 00:33:22,110
Copy assignment operator.

540
00:33:22,390 --> 00:33:23,700
So it is our operator.

541
00:33:23,710 --> 00:33:28,390
So what we have to do we have to overload this operator and we have started about operator overloading

542
00:33:28,390 --> 00:33:28,760
a lot.

543
00:33:29,500 --> 00:33:33,680
So what we have to do we have to adjust our load equal operator.

544
00:33:33,850 --> 00:33:38,270
So we're dealing with the return type so certain types will be void.

545
00:33:38,330 --> 00:33:39,960
We are not returning anything.

546
00:33:40,130 --> 00:33:42,430
And operator keyword.

547
00:33:42,710 --> 00:33:46,520
I won't overload equal operator what it will take as argument.

548
00:33:46,520 --> 00:33:54,410
It will take our dynamic any and how it will take it will take by constant reference and let's say my

549
00:33:54,410 --> 00:33:55,920
name is D.

550
00:33:56,030 --> 00:33:58,160
Okay so what is happening here is.

551
00:33:58,250 --> 00:34:02,040
So what do the code the code will be exactly the same.

552
00:34:02,060 --> 00:34:02,320
Okay.

553
00:34:02,330 --> 00:34:03,830
It will be exactly the same.

554
00:34:03,830 --> 00:34:07,700
The code which was what copy constructor okay.

555
00:34:07,810 --> 00:34:09,030
Exactly same code.

556
00:34:09,060 --> 00:34:15,810
So inside the equal operator inside the copy assignment operator it also creates the shallow copy but

557
00:34:15,810 --> 00:34:17,430
we have to create the copy.

558
00:34:17,430 --> 00:34:19,490
So we overloaded the operator.

559
00:34:19,620 --> 00:34:19,890
Okay.

560
00:34:19,920 --> 00:34:20,910
So how it will call

561
00:34:24,560 --> 00:34:35,170
Sylvia creating dynamic at a let's call it do to and then we are using copy assignment operators are

562
00:34:35,180 --> 00:34:36,320
duty question given.

563
00:34:36,470 --> 00:34:43,730
So this thing will go in this and it will move past this argument okay.

564
00:34:43,860 --> 00:34:45,530
So argument means here.

565
00:34:47,040 --> 00:34:47,460
Okay.

566
00:34:47,460 --> 00:34:48,580
And this.

567
00:34:48,660 --> 00:34:49,510
So this.

568
00:34:49,560 --> 00:34:50,440
Okay.

569
00:34:50,610 --> 00:34:52,840
I hope you know everything.

570
00:34:53,460 --> 00:34:54,720
Okay.

571
00:34:55,200 --> 00:35:01,910
So now let's send this file and now give it all to her and this file.

572
00:35:01,980 --> 00:35:04,570
So now we can see Ben.

573
00:35:04,590 --> 00:35:04,860
Okay.

574
00:35:04,890 --> 00:35:08,570
So the tree is also not getting affected by doing changes isn't even.

575
00:35:08,640 --> 00:35:11,440
So now even you and D.T. they are independent.

576
00:35:11,670 --> 00:35:11,940
Okay.

577
00:35:11,940 --> 00:35:13,890
They can work properly.

578
00:35:13,890 --> 00:35:18,030
Now let us create one more constructor so this to him.

579
00:35:18,030 --> 00:35:20,350
Let us create one parameter based constructor.

580
00:35:20,550 --> 00:35:25,930
Okay so our dynamic array lets say the user wants to give the value of capacity.

581
00:35:25,950 --> 00:35:33,400
Okay so let's say use I will give the value of capacity then issue the size of the array so data is

582
00:35:33,960 --> 00:35:46,460
I will create the array of size see so the next index it will be simply zero and the capacity will be

583
00:35:46,970 --> 00:35:47,970
C.

584
00:35:48,170 --> 00:35:53,470
Okay.

585
00:35:53,690 --> 00:35:55,140
So now let us.

586
00:35:55,190 --> 00:36:02,460
So now what happens is user can create an array of the size he wants initially.

587
00:36:02,460 --> 00:36:05,350
Let's say initially he wants array of size hundred.

588
00:36:05,390 --> 00:36:10,900
So we will be able to create an array of size ended by using parameters constructors or default or to

589
00:36:10,900 --> 00:36:11,990
get capacity

590
00:36:16,440 --> 00:36:22,700
OK and here what we have better make price constructors what better met paramedics constructor there

591
00:36:22,870 --> 00:36:27,000
is no need to write out because default.

592
00:36:27,030 --> 00:36:28,840
That's my desk constructor does not exist.

593
00:36:29,310 --> 00:36:31,950
So this is better my best constructor when we will do default.

594
00:36:31,950 --> 00:36:34,830
Get capacity out all our output will be rendered.

595
00:36:34,890 --> 00:36:35,160
Okay

596
00:36:39,180 --> 00:36:39,500
okay.

597
00:36:39,510 --> 00:36:41,630
So I think we've all got to run this file

598
00:36:51,960 --> 00:36:55,680
all again silly mistake.

599
00:36:55,750 --> 00:37:01,940
We forgot to print.

600
00:37:02,140 --> 00:37:03,550
So now we can.

601
00:37:03,580 --> 00:37:04,600
So in our diary.

602
00:37:04,600 --> 00:37:07,320
So now the size of the default object is.

603
00:37:07,330 --> 00:37:07,820
Hundred.

604
00:37:07,870 --> 00:37:08,440
Okay.

605
00:37:08,560 --> 00:37:09,520
The size of that is.

606
00:37:09,520 --> 00:37:10,170
Hundred.

607
00:37:10,180 --> 00:37:16,270
So in this way user can if user want he can give the size of the array initially.

608
00:37:16,270 --> 00:37:18,820
Okay so now we have to read about constraint function.

609
00:37:18,820 --> 00:37:20,370
Let's say let's see.

610
00:37:20,380 --> 00:37:22,570
So can this function be a constraint function.

611
00:37:22,600 --> 00:37:27,070
Yes it it qualifies for a constraint function because it is not changing the properties of the current

612
00:37:27,070 --> 00:37:28,020
object.

613
00:37:28,030 --> 00:37:30,540
Similarly print is also a constraint function.

614
00:37:30,550 --> 00:37:33,100
It is not changing the properties of the current object.

615
00:37:33,160 --> 00:37:37,100
Get this all to a constraint function it is not changing the properties of the current object.

616
00:37:38,620 --> 00:37:42,400
So can this function add to be a constraint or question function.

617
00:37:42,400 --> 00:37:43,150
No.

618
00:37:43,210 --> 00:37:43,730
Why.

619
00:37:43,780 --> 00:37:47,200
Because it is changing the properties of the current object.

620
00:37:47,200 --> 00:37:51,280
Similarly this added function is also an order constraint function.

621
00:37:51,280 --> 00:37:56,410
So operator No this is changing the property of this current object.

622
00:37:56,410 --> 00:37:57,100
No no no.

623
00:37:57,160 --> 00:37:57,430
Okay.

624
00:37:57,430 --> 00:38:06,100
So only get capacity print and get function if you want you can write.

625
00:38:06,220 --> 00:38:08,810
Name this get element.

626
00:38:09,110 --> 00:38:09,400
Okay.

627
00:38:10,320 --> 00:38:13,020
Okay so we forgot to test this function.

628
00:38:13,050 --> 00:38:15,790
We forgot to test get element function.

629
00:38:15,790 --> 00:38:18,140
So let's test this function also.

630
00:38:22,730 --> 00:38:28,920
So let's get see out get element.

631
00:38:29,250 --> 00:38:31,860
Okay so see our Deven not

632
00:38:34,550 --> 00:38:38,680
get the element so which element do we want.

633
00:38:38,800 --> 00:38:42,220
Now let's see the element present at index 0.

634
00:38:42,220 --> 00:38:42,430
Okay

635
00:38:49,160 --> 00:38:56,300
so the element has entered index 0 waste and and ready if I do element present at index 5.

636
00:38:56,400 --> 00:38:57,960
So the output will be 60

637
00:39:01,290 --> 00:39:02,670
so that would produce 60.

638
00:39:02,790 --> 00:39:10,100
And what if the index is not valid let's say six so there is nothing present at index X or let's say

639
00:39:10,100 --> 00:39:16,650
you make it then there is nothing present at index 10 so we'll get minus 1.

640
00:39:16,730 --> 00:39:17,030
Okay.

641
00:39:17,060 --> 00:39:23,410
So by default if you see here we are attending minus one so that it is done minus one.

642
00:39:23,570 --> 00:39:27,640
Okay and what if the index is negative so minus 10.

643
00:39:27,770 --> 00:39:34,160
Again we will get negative 1 Okay.

644
00:39:34,340 --> 00:39:40,200
So I think we have tested everything.

645
00:39:40,310 --> 00:39:46,850
Yes I think according to me we have tested everything okay so we have tested our code completely.

646
00:39:46,890 --> 00:39:49,770
So if you have any doubt you can ask me whenever you want.

647
00:39:49,890 --> 00:39:52,730
Okay so I hope you understood this really completely.

648
00:39:53,340 --> 00:39:53,950
Okay.

649
00:39:54,030 --> 00:39:54,480
Thank you.
