1
00:00:02,340 --> 00:00:03,030
Hello everyone.

2
00:00:03,030 --> 00:00:07,110
So in the last video we discussed overloading the incremental operator.

3
00:00:07,110 --> 00:00:09,650
I hope that is clear in this video.

4
00:00:09,660 --> 00:00:12,270
We will try to overload a few more operators.

5
00:00:12,300 --> 00:00:15,710
Okay so let's start with the plus plus operator.

6
00:00:15,720 --> 00:00:20,470
So let's start with the post increment operator.

7
00:00:20,860 --> 00:00:21,170
Okay.

8
00:00:21,190 --> 00:00:25,650
So in this video we will try to overload post increment operator.

9
00:00:26,020 --> 00:00:26,220
Okay.

10
00:00:26,230 --> 00:00:28,600
So this is a unity operator.

11
00:00:29,020 --> 00:00:29,250
Okay.

12
00:00:29,260 --> 00:00:34,000
So how we will call friction f1 plus plus.

13
00:00:34,000 --> 00:00:34,270
Okay.

14
00:00:34,280 --> 00:00:40,770
Since this is a unity operator so F1 will go in this and there is no need to pass any argument.

15
00:00:41,110 --> 00:00:41,580
Okay.

16
00:00:41,650 --> 00:00:47,290
So first let us try to first let us revise the defense within the pre and post increment.

17
00:00:47,320 --> 00:00:48,400
Okay.

18
00:00:48,400 --> 00:01:01,530
So pre and post so there defenses see if I write and die is 5 and I bless plus and if I tried to print

19
00:01:01,530 --> 00:01:02,520
the value off.

20
00:01:03,100 --> 00:01:06,170
So this is P so plus plus I.

21
00:01:06,510 --> 00:01:08,190
And if I tried to print the value of i.

22
00:01:08,220 --> 00:01:09,690
So the output will be 6.

23
00:01:09,720 --> 00:01:10,410
Okay.

24
00:01:10,410 --> 00:01:21,210
And similarly if I had to post increment and if I tried to print the value of my then I said will be

25
00:01:21,210 --> 00:01:21,780
six.

26
00:01:21,800 --> 00:01:23,980
So here that there is no difference.

27
00:01:24,230 --> 00:01:27,510
The difference would have come when we will assign the values.

28
00:01:27,530 --> 00:01:27,790
Okay.

29
00:01:27,810 --> 00:01:32,000
So the difference between post and increment will come when we will assign the values.

30
00:01:32,000 --> 00:01:34,010
So let us assign the values.

31
00:01:34,010 --> 00:01:35,770
So in the G.

32
00:01:35,940 --> 00:01:38,000
This is less policy.

33
00:01:38,310 --> 00:01:40,980
And now let's try to bend the value of i n g

34
00:01:44,590 --> 00:01:45,160
similarly

35
00:01:50,340 --> 00:01:54,450
I plus press and brand the value of i n g

36
00:01:58,230 --> 00:02:03,550
so the value of i will be 6 and the value of G will also be 6.

37
00:02:03,630 --> 00:02:05,890
In this case the value of i will be 6.

38
00:02:05,910 --> 00:02:08,760
But the value of j will be five.

39
00:02:08,850 --> 00:02:09,280
Okay.

40
00:02:09,360 --> 00:02:16,180
So what happened is breeding commences first increment and then use.

41
00:02:16,230 --> 00:02:18,050
Okay so that's why a six and 6.

42
00:02:18,210 --> 00:02:23,870
Whereas post increment will say first assign first to use and then increment.

43
00:02:25,020 --> 00:02:25,290
Okay.

44
00:02:25,320 --> 00:02:29,700
So the defense will come when we will assign the values.

45
00:02:29,700 --> 00:02:30,270
Okay.

46
00:02:30,270 --> 00:02:33,300
Now how we will differentiate in diffraction plots.

47
00:02:33,330 --> 00:02:33,860
Okay.

48
00:02:33,900 --> 00:02:40,520
So what will happen infection plus how we will call the function so we will write something like

49
00:02:43,160 --> 00:02:49,090
fiction if food is f 1 plus plus.

50
00:02:49,090 --> 00:02:57,610
So let us assume the initial value of f1 is so numerator and denominator is that certain by two.

51
00:02:57,660 --> 00:03:03,500
So this is initially F1 so posting I will say first assign and then increment.

52
00:03:04,320 --> 00:03:10,140
So the value of a fourth will be same as the value of f1 so then n2.

53
00:03:10,170 --> 00:03:11,880
So this will be our effort.

54
00:03:12,660 --> 00:03:16,940
And for F1 which will happen we will do plus 1 and then we will call simplifying.

55
00:03:16,960 --> 00:03:20,410
So it will become 6 by 1.

56
00:03:20,520 --> 00:03:21,150
Okay.

57
00:03:21,180 --> 00:03:23,400
So this will be the value of f1.

58
00:03:24,270 --> 00:03:27,180
Okay so let us all load the function post increment.

59
00:03:27,210 --> 00:03:27,900
Let us order.

60
00:03:27,940 --> 00:03:29,470
Operator post increment.

61
00:03:29,490 --> 00:03:33,770
Okay so what we will do we have to return a fraction and their function.

62
00:03:33,780 --> 00:03:35,220
We have to return the all the value.

63
00:03:35,250 --> 00:03:38,710
So this is the old value and this is the new value.

64
00:03:38,730 --> 00:03:39,780
Okay.

65
00:03:40,050 --> 00:03:41,640
So now let's see called

66
00:03:45,930 --> 00:03:52,620
so it's time to overload post increment.

67
00:03:52,870 --> 00:03:59,270
Okay so first of all work with the return type return type cannot be void because we have to return

68
00:03:59,270 --> 00:04:02,890
type cannot be void because we can also assign values.

69
00:04:02,900 --> 00:04:07,320
Okay so that's why than type cannot be void then they will be function only.

70
00:04:07,790 --> 00:04:13,090
And then operator and then operator which we want to overload.

71
00:04:13,280 --> 00:04:21,180
So it will not take any argument why because would say unity operator now see the name of the function

72
00:04:21,180 --> 00:04:24,130
is exactly the same operator plus and operator plus.

73
00:04:24,150 --> 00:04:27,600
So how do differentiate between the P and the post increment.

74
00:04:27,600 --> 00:04:30,520
So what we will do we will write in budget here.

75
00:04:30,600 --> 00:04:31,250
Okay.

76
00:04:31,260 --> 00:04:36,300
So now this is post increment and that bonus pre increment.

77
00:04:36,330 --> 00:04:36,840
Okay.

78
00:04:36,900 --> 00:04:41,150
So you have to remember this that we have to pass in budget as argument.

79
00:04:41,310 --> 00:04:41,840
Okay.

80
00:04:41,940 --> 00:04:46,330
So what we have to do first of all we have to write down the friction and the friction with the all

81
00:04:46,330 --> 00:04:47,130
the values.

82
00:04:47,160 --> 00:04:47,810
Okay.

83
00:04:47,910 --> 00:04:49,530
So friction with the all the values.

84
00:04:49,560 --> 00:04:58,230
So friction if new it will contain the numerator and denominator.

85
00:04:58,350 --> 00:05:03,810
And now what we have to do first first use and then increment.

86
00:05:03,840 --> 00:05:04,930
Now we will increment.

87
00:05:04,970 --> 00:05:13,590
So the numerator will become numerator plus denominator and the denominator will remain unchanged.

88
00:05:13,740 --> 00:05:20,940
Then what we have to do we have to call simplify function so simplify so implicitly it will be called

89
00:05:20,940 --> 00:05:24,210
on this side or simplify okay.

90
00:05:24,270 --> 00:05:28,940
Now we have to return direction so that it can start.

91
00:05:28,960 --> 00:05:34,280
Sorry we have to return the old friction and so f new.

92
00:05:34,290 --> 00:05:34,560
Okay.

93
00:05:34,560 --> 00:05:41,140
So what will happen.

94
00:05:41,240 --> 00:05:44,720
So this is F1 numerator and denominator.

95
00:05:44,720 --> 00:05:50,500
Value is tending to and suits at doses so hundred.

96
00:05:50,550 --> 00:05:55,210
Okay so this will contain 700.

97
00:05:55,470 --> 00:05:57,940
So I am creating a new fraction f new.

98
00:05:58,170 --> 00:06:02,710
So we have a new friction no days down the runway.

99
00:06:02,720 --> 00:06:04,080
That is true.

100
00:06:04,120 --> 00:06:07,830
This is f new okay.

101
00:06:07,890 --> 00:06:10,290
And let's say you said this is 800.

102
00:06:10,290 --> 00:06:12,540
So numerator is numerator plus no matter.

103
00:06:12,810 --> 00:06:15,030
So who is no better that this error numerator.

104
00:06:15,330 --> 00:06:17,060
So 700 nobody knows.

105
00:06:17,070 --> 00:06:22,500
So it will become 20 and this will remain as true then we are calling the simplified function.

106
00:06:22,500 --> 00:06:25,630
So simplify we make it 6 by 1.

107
00:06:25,920 --> 00:06:26,190
Okay.

108
00:06:26,190 --> 00:06:28,140
And then we added dining f new.

109
00:06:28,200 --> 00:06:31,140
So then we will return this one.

110
00:06:31,140 --> 00:06:33,850
Okay so let's do one more thing.

111
00:06:33,960 --> 00:06:39,090
Let us also simplify this friction so it will become 5 by 1.

112
00:06:39,240 --> 00:06:39,490
Okay.

113
00:06:39,510 --> 00:06:42,180
So let us call simplify function on f new

114
00:06:45,470 --> 00:06:48,910
so f new not simplify

115
00:06:53,840 --> 00:06:54,110
okay.

116
00:07:06,490 --> 00:07:08,300
Now there does create a friction if three

117
00:07:15,140 --> 00:07:23,920
so let's create a fraction F3 and we will use post incrementally we'll call post increment.

118
00:07:23,950 --> 00:07:33,460
Okay so f one less plus and now we will print f linen F three so f t not print.

119
00:07:33,640 --> 00:07:35,170
Okay so what should be our output.

120
00:07:40,390 --> 00:07:40,620
Okay.

121
00:07:40,630 --> 00:07:46,430
So since we are calling post incremental first F when will be assigned to F3.

122
00:07:46,600 --> 00:07:52,390
So the value of F2 will be 5 by 1 because we are also calling simplify function and then f one will

123
00:07:52,390 --> 00:07:53,370
be incremented.

124
00:07:53,500 --> 00:07:56,350
So the value of f 1 will be 6 by 1.

125
00:07:56,350 --> 00:07:58,940
So that would probably be 6 by 1 and 5 7.

126
00:07:58,960 --> 00:07:59,920
Okay so let's see

127
00:08:03,640 --> 00:08:06,060
so that would produce 6 by 1 in 5 by 1.

128
00:08:06,110 --> 00:08:06,340
Okay.

129
00:08:06,350 --> 00:08:09,960
So our code is working now let's see when.

130
00:08:13,180 --> 00:08:13,900
If I had 8

131
00:08:16,930 --> 00:08:24,880
and day is 5 and I bless bless and bless bliss.

132
00:08:24,960 --> 00:08:27,720
And if I tried to pray in the valley of I.

133
00:08:27,750 --> 00:08:29,220
So what do we are output.

134
00:08:29,220 --> 00:08:35,990
So what I'm doing here is we are doing nesting nesting one post increment so it will throw us at it.

135
00:08:36,000 --> 00:08:36,230
Okay.

136
00:08:36,240 --> 00:08:39,350
So nesting is not defined for post increment.

137
00:08:39,360 --> 00:08:39,590
Okay.

138
00:08:39,600 --> 00:08:42,290
So nesting is not allowed for posting agreement.

139
00:08:42,300 --> 00:08:45,120
So since nesting is not allowed.

140
00:08:45,150 --> 00:08:47,910
So since nesting is not allowed for posting agreement.

141
00:08:48,060 --> 00:08:49,070
So we will not do.

142
00:08:49,080 --> 00:08:52,440
Okay so there is no need for us to do nesting.

143
00:08:53,070 --> 00:08:56,410
Okay so if you will ring discord this will throw us at it.

144
00:08:57,060 --> 00:09:00,180
Similarly our God will give us unexpected output.

145
00:09:00,300 --> 00:09:00,570
Okay.

146
00:09:00,620 --> 00:09:04,520
So very strange behavior will be observed okay.

147
00:09:04,540 --> 00:09:09,350
So now let's stop let's stop posting agreement here.

148
00:09:09,400 --> 00:09:14,640
Now let us try to overload one more operator which is called Blessed collaborator.

149
00:09:14,650 --> 00:09:17,680
So now we will try to overload classical operator.

150
00:09:18,340 --> 00:09:18,620
Okay.

151
00:09:18,670 --> 00:09:20,040
So where this political operator.

152
00:09:20,050 --> 00:09:25,910
So when I write in day 5 and geez let's say 3.

153
00:09:26,110 --> 00:09:28,950
So if I do I plus equals G.

154
00:09:28,960 --> 00:09:33,760
So this is basically the short form of writing I equals a plus G.

155
00:09:33,850 --> 00:09:35,140
Okay so what will happen.

156
00:09:35,320 --> 00:09:40,790
The value of AI is initially 5 and the value of G is initially 3.

157
00:09:40,810 --> 00:09:43,380
So after this line it will become it.

158
00:09:44,080 --> 00:09:44,340
Okay.

159
00:09:44,350 --> 00:09:46,180
So add the two values and put that in there.

160
00:09:46,180 --> 00:09:49,470
Then I okay.

161
00:09:49,760 --> 00:09:54,270
So for political operator nesting is defined.

162
00:09:54,360 --> 00:10:03,140
Okay so if I write I plus equal g and then if I do the nesting blessed with G so output will become.

163
00:10:03,140 --> 00:10:04,910
So this will be done.

164
00:10:05,000 --> 00:10:08,870
This will make the value of phys it and then we are doing plus it goes to you.

165
00:10:08,870 --> 00:10:12,370
So this will become 11 and it will remain three.

166
00:10:12,440 --> 00:10:16,110
Okay so the value of 5 will become eleven and the value of j will remain three.

167
00:10:16,190 --> 00:10:16,490
Okay.

168
00:10:16,520 --> 00:10:18,620
So this operator has nesting properties.

169
00:10:18,650 --> 00:10:20,590
Okay so nesting is allowed.

170
00:10:20,660 --> 00:10:22,410
So let's see.

171
00:10:22,820 --> 00:10:25,760
Let's try to experiment first.

172
00:10:25,800 --> 00:10:35,710
So what I'm doing in day is 5 and into juice 3 now I plus a equals G

173
00:10:40,990 --> 00:10:43,400
similarly plus equals G.

174
00:10:43,420 --> 00:10:46,030
Now if I tried to print the value of i in J

175
00:10:51,160 --> 00:10:59,100
So that would probably be eleven and three guess it output is eleven and

176
00:11:04,720 --> 00:11:06,830
so the output is eleven entry.

177
00:11:06,830 --> 00:11:07,400
Okay.

178
00:11:07,520 --> 00:11:08,930
So nesting is defined.

179
00:11:08,930 --> 00:11:13,760
So that means we have to also uh keep this in mind divide overloading the operator.

180
00:11:14,210 --> 00:11:14,620
Okay.

181
00:11:14,720 --> 00:11:16,250
So how we will call our function

182
00:11:22,680 --> 00:11:29,380
so we call something like this friction F1 plus it equals friction F2 since it is a binary operator.

183
00:11:29,460 --> 00:11:35,050
So the F1 will go in this and F2 will be parsed as argument.

184
00:11:35,260 --> 00:11:42,310
Okay so this simply means F1 is F1 plus F2.

185
00:11:42,410 --> 00:11:42,680
Okay.

186
00:11:42,690 --> 00:11:46,890
So we are adding two functions and put the desert inflection one.

187
00:11:46,920 --> 00:11:47,320
Okay.

188
00:11:47,400 --> 00:11:51,980
So if you see we have already done this function if you remember the add function.

189
00:11:51,990 --> 00:11:56,890
So the function idea of ADD was something like this only okay.

190
00:11:57,330 --> 00:12:00,620
So now let us see in code.

191
00:12:00,660 --> 00:12:01,220
Okay.

192
00:12:01,320 --> 00:12:03,720
So first of all what we the return type.

193
00:12:03,750 --> 00:12:09,580
So the return type will be a fraction we are returning a fraction then since the nesting is allowed.

194
00:12:10,290 --> 00:12:12,130
We will return biodefense.

195
00:12:12,150 --> 00:12:12,590
Okay.

196
00:12:12,630 --> 00:12:18,790
We have to return a fraction biodefense via biodefense because the nesting is allowed okay.

197
00:12:20,640 --> 00:12:23,940
So let's see okay.

198
00:12:23,960 --> 00:12:28,340
So let's see.

199
00:12:28,380 --> 00:12:32,940
So first of all what do we the return types to return that will be a fraction.

200
00:12:32,940 --> 00:12:33,250
Okay.

201
00:12:33,270 --> 00:12:34,770
So why affliction.

202
00:12:34,890 --> 00:12:37,080
Because we need to return affection.

203
00:12:37,080 --> 00:12:40,050
It cannot be void and then operator keyword.

204
00:12:40,380 --> 00:12:46,140
And the operative which we want to overload plus equal so it would but it will take it will take a fraction

205
00:12:46,140 --> 00:12:53,440
as input and fiction if two now we know about gold standard offenses.

206
00:12:53,480 --> 00:12:57,620
So we will pass constant traffic because you do not want to call copy constructor.

207
00:12:57,620 --> 00:13:00,460
And also we want to avoid any legal changes.

208
00:13:00,490 --> 00:13:01,180
Okay.

209
00:13:01,250 --> 00:13:04,610
So the functionality will be same as add function.

210
00:13:04,610 --> 00:13:06,050
So there is added function

211
00:13:09,850 --> 00:13:10,160
okay.

212
00:13:10,180 --> 00:13:11,610
So this is our idea function.

213
00:13:11,890 --> 00:13:12,940
So we'll copy discord

214
00:13:17,280 --> 00:13:17,520
okay.

215
00:13:17,530 --> 00:13:22,550
So what we have to do here is we have to make the changes in F1 only.

216
00:13:22,560 --> 00:13:23,250
Okay.

217
00:13:23,360 --> 00:13:29,220
So oncoming discord and we do not need this code

218
00:13:33,110 --> 00:13:33,530
okay.

219
00:13:38,940 --> 00:13:39,170
Okay.

220
00:13:39,180 --> 00:13:44,610
So once the numerator and denominator is updated we have to call the simplify function.

221
00:13:44,610 --> 00:13:52,960
So after cutting the simplify function we also have to it done so right then stop this okay.

222
00:13:53,140 --> 00:13:53,770
Now let's see

223
00:13:56,850 --> 00:14:02,600
now let us first take two functions and see what will be our output.

224
00:14:02,620 --> 00:14:03,060
So.

225
00:14:03,900 --> 00:14:06,250
So let's say I have two factions F1 and F2.

226
00:14:06,250 --> 00:14:11,080
So for F1 the values of the numerator and denominator is let's say 10 entry.

227
00:14:11,080 --> 00:14:18,910
So this is fraction F1 and for fraction F2 let's say the values are 5 and 2.

228
00:14:19,060 --> 00:14:24,760
So this is friction to address 800 and address 700.

229
00:14:24,820 --> 00:14:25,050
Okay.

230
00:14:25,080 --> 00:14:29,100
So when we add these to fiction what will be our output.

231
00:14:29,170 --> 00:14:32,000
So our output will we assemble basics.

232
00:14:32,020 --> 00:14:37,400
This is 20 plus 15 and this is tied to five by six.

233
00:14:37,410 --> 00:14:41,890
So after calling the simplify function output will we try to five by six only.

234
00:14:41,910 --> 00:14:43,630
Okay so this is our output.

235
00:14:43,830 --> 00:14:48,690
Now how we will call this function we will call the function f plus equals F2.

236
00:14:49,140 --> 00:14:49,680
Okay.

237
00:14:49,680 --> 00:14:51,540
So F2 will remain unchanged.

238
00:14:51,570 --> 00:14:55,290
So the value of have to will remain same as 5 by 2.

239
00:14:55,680 --> 00:14:58,500
And F1 will become 25 by 6.

240
00:14:58,770 --> 00:14:59,030
Okay.

241
00:14:59,040 --> 00:15:04,260
So we are doing we are calculating that I'll see him and then we are updating the numerator and then

242
00:15:04,270 --> 00:15:05,820
do a matter of this.

243
00:15:06,180 --> 00:15:08,780
And this contains 700 basically F1.

244
00:15:09,390 --> 00:15:14,050
Okay then we are calling this employ function and then we are returning F1.

245
00:15:14,320 --> 00:15:14,640
Okay.

246
00:15:14,670 --> 00:15:43,010
So let's see.

247
00:15:43,080 --> 00:15:49,360
So how will you call the functions F1 plus equals F2.

248
00:15:49,410 --> 00:15:54,000
So first of all let us change the values of a finite F2 as we have discussed.

249
00:15:54,060 --> 00:16:04,530
So the value of f1 was 10 by three and the value of after was five by 2 5 and 2.

250
00:16:04,600 --> 00:16:06,720
Okay so our output will be 35 by 6.

251
00:16:06,720 --> 00:16:10,830
Now let us try to bring the value of f1 f2 so F1 nought point.

252
00:16:11,250 --> 00:16:13,940
And similarly after that print.

253
00:16:14,070 --> 00:16:20,040
So the value of two will remain unchanged and the value of f1 it will become five by six.

254
00:16:20,100 --> 00:16:20,370
Okay

255
00:16:24,950 --> 00:16:29,700
so the value of f1 became 25 by 6 and the value of employees 5 by two.

256
00:16:29,720 --> 00:16:30,210
Okay.

257
00:16:30,260 --> 00:16:32,170
So our code is working fine.

258
00:16:32,180 --> 00:16:32,410
Okay.

259
00:16:32,420 --> 00:16:38,060
So one more thing I hope you understand why we need to pass by reference written by reference.

260
00:16:38,060 --> 00:16:38,800
Okay.

261
00:16:38,850 --> 00:16:46,190
Y written by reference because if you will write if you will write like F1 plus equals F2

262
00:16:51,660 --> 00:16:54,510
and then again plus equals F2 if you will do nesting.

263
00:16:55,050 --> 00:17:01,710
So I feel lighter than biodefense than the output of this thing will be a system before a system or

264
00:17:01,710 --> 00:17:02,850
temporary memory.

265
00:17:02,850 --> 00:17:07,200
And this second plus equals two will work on that system memory.

266
00:17:07,260 --> 00:17:08,820
Okay so that will be wrong.

267
00:17:08,850 --> 00:17:09,090
Okay.

268
00:17:09,090 --> 00:17:11,460
We do not want it to work on system copy.

269
00:17:11,910 --> 00:17:14,990
So that's why we have to write down by reference.

270
00:17:15,230 --> 00:17:16,070
Okay.

271
00:17:16,340 --> 00:17:19,970
So if you want to condemn this file let us

272
00:17:36,230 --> 00:17:36,460
okay.

273
00:17:36,470 --> 00:17:37,640
So now that's in this file

274
00:17:41,190 --> 00:17:46,330
so F2 remains unchanged and the value of f1 is 25 by three which I'm assuming is correct.

275
00:17:46,500 --> 00:17:47,100
Okay.

276
00:17:47,370 --> 00:17:50,100
So why we need to return biodefense.

277
00:17:50,670 --> 00:17:59,120
So if you will not written by defence the output of this part it will be a system copy it will be a

278
00:17:59,120 --> 00:18:01,640
system copy and this second plus equals two.

279
00:18:01,640 --> 00:18:04,790
This will work on the system copy which we do not want.

280
00:18:04,850 --> 00:18:07,610
Okay so that's why we have the written by reference.

281
00:18:07,670 --> 00:18:08,270
Okay.

282
00:18:08,360 --> 00:18:12,470
So I think we have all loaded almost all the imprint operators.

283
00:18:12,470 --> 00:18:14,690
So if you have any doubt feel free to ask.

284
00:18:14,690 --> 00:18:15,140
Okay.

285
00:18:15,200 --> 00:18:15,620
Thank you.
