1
00:00:01,890 --> 00:00:02,610
Hello everyone.

2
00:00:02,610 --> 00:00:07,190
So in this session we will learn a few more important concepts of object oriented programming.

3
00:00:07,200 --> 00:00:18,850
So before starting today's glass let us try something so when we write so when we write in day 5 what

4
00:00:18,850 --> 00:00:23,070
will happen we will get a memory block A and it contains the value five.

5
00:00:23,830 --> 00:00:33,520
Similarly if I want to create a budget constraint where does this index end questioned BTC.

6
00:00:33,560 --> 00:00:34,970
So at this vein what will happen.

7
00:00:34,970 --> 00:00:38,610
I will get a memory block B and it will contain five.

8
00:00:38,650 --> 00:00:42,200
Okay so we can write constants before integer or after integer.

9
00:00:42,320 --> 00:00:45,060
Okay so let's have a choice now.

10
00:00:45,110 --> 00:00:47,780
Can I break this line into two parts.

11
00:00:47,870 --> 00:00:50,090
I can make this statement and do two lines.

12
00:00:50,390 --> 00:00:54,620
So the first line is in a and the second is a S5.

13
00:00:54,710 --> 00:00:55,490
So I had this line.

14
00:00:55,520 --> 00:01:02,400
I will get a and it contains a garbage value and at this line I'm overriding the garbage value with

15
00:01:02,400 --> 00:01:03,130
the value five.

16
00:01:04,190 --> 00:01:08,190
Similarly Can I break this line into two parts and do two statements.

17
00:01:08,210 --> 00:01:14,870
So the first treatment will be I'm creating I integer constant so integer constraint B and it's second

18
00:01:14,870 --> 00:01:15,770
line.

19
00:01:15,770 --> 00:01:17,040
I will copy the value.

20
00:01:17,600 --> 00:01:19,340
So at this point what will happen.

21
00:01:19,340 --> 00:01:24,980
I will get time to Block B and it will contain I'm gonna visually enter this line.

22
00:01:24,980 --> 00:01:29,760
What we are trying to do here is we are trying to overwrite this garbage value with the value 5.

23
00:01:29,780 --> 00:01:38,150
So this line will throw us at it via error because we can see here is integer constraint we cannot change

24
00:01:38,150 --> 00:01:40,220
the value of B once it is assigned.

25
00:01:40,220 --> 00:01:45,860
So at this line B contains the garbage value B contains garbage value and at this land we are trying

26
00:01:45,860 --> 00:01:48,040
to override the garbage value with the value 5.

27
00:01:48,080 --> 00:01:50,010
So we will get an error at this line.

28
00:01:50,780 --> 00:01:54,560
So before getting error at this line we will get error at this line.

29
00:01:54,680 --> 00:01:55,620
So why an error.

30
00:01:55,640 --> 00:02:02,160
This line compiler will throw error at this line because what we are trying to do here is we are creating

31
00:02:02,160 --> 00:02:03,770
an integer constant.

32
00:02:03,930 --> 00:02:09,030
We are creating a digital content and adding digit constant contains a garbage value.

33
00:02:09,840 --> 00:02:10,120
Okay.

34
00:02:10,140 --> 00:02:15,330
So don't be a constraint on Basic garbage value basically that we lose use less what is okay since it

35
00:02:15,330 --> 00:02:16,670
contains the garbage value.

36
00:02:16,700 --> 00:02:20,390
So it is useless for us compiler will not allow us to do this.

37
00:02:20,400 --> 00:02:25,020
So what we have to do we have to initialize the constraint we have to finish that's the constraint variables

38
00:02:25,080 --> 00:02:27,180
at the time of its creation.

39
00:02:27,180 --> 00:02:28,790
Okay so this line is correct.

40
00:02:28,830 --> 00:02:32,610
We have to initialize the constraint variable at the time of its creation.

41
00:02:32,610 --> 00:02:35,190
Now let us take one more example.

42
00:02:35,190 --> 00:02:44,920
So and day is 5 so I really get my memory block I and it contains the value 5.

43
00:02:44,960 --> 00:02:49,810
Now I want to create that offense variable so of variable G is a.

44
00:02:49,930 --> 00:02:52,240
So the name of this block is also G.

45
00:02:52,450 --> 00:02:56,880
Okay so both I enjoy points to this memory location.

46
00:02:57,040 --> 00:03:00,490
Now can I break this line into two parts into two statements.

47
00:03:00,490 --> 00:03:07,690
So the first statement is create a reference variable and the second statement points to J will point

48
00:03:07,690 --> 00:03:08,380
do I.

49
00:03:08,500 --> 00:03:11,190
Okay so again what will happen.

50
00:03:11,190 --> 00:03:12,150
We will get better.

51
00:03:12,180 --> 00:03:19,530
This line so just like the constant variables it is compulsory to give the value of a reference variable

52
00:03:19,530 --> 00:03:20,970
at the time of its creation.

53
00:03:20,970 --> 00:03:28,130
Okay so at this line what will happen it will contain it will point to a garbage memory location okay

54
00:03:28,160 --> 00:03:30,920
so compiler will not allow us to do this.

55
00:03:30,980 --> 00:03:37,910
Okay so for constraint and for reference variable for constraint and for reference variable we have

56
00:03:37,910 --> 00:03:43,930
to give their value at the time of their creation at the time of the memory allocation okay.

57
00:03:43,940 --> 00:03:44,960
Now let's see in code

58
00:03:51,150 --> 00:03:52,680
so I have a class here.

59
00:03:52,680 --> 00:03:56,630
Student So this student contains two public properties each and William.

60
00:03:56,630 --> 00:03:58,890
But now my aim is very simple.

61
00:03:58,890 --> 00:04:02,820
What I want is what we want is once the roll number is set.

62
00:04:02,880 --> 00:04:06,510
It cannot be changed similarly.

63
00:04:06,510 --> 00:04:12,490
So what we have to do here if we write C++ then it will throw at it.

64
00:04:12,780 --> 00:04:17,100
It will throw Error because B's in beta constant B's integer constant.

65
00:04:17,100 --> 00:04:22,770
Similarly my aim is once the value of the lumber is set but the value of raw lumber is set.

66
00:04:23,190 --> 00:04:24,600
I cannot change it.

67
00:04:24,630 --> 00:04:30,060
So what we have to do we have to make it IPG constant so we can write construct before integer or after

68
00:04:30,060 --> 00:04:30,510
ingredient.

69
00:04:30,510 --> 00:04:35,720
So here I am writing question before integer okay.

70
00:04:36,010 --> 00:04:44,810
Now let us create objects so student S1 not a desk tried to change the values of a general number.

71
00:04:44,840 --> 00:04:55,110
Okay so as one dot age lets certain and S1 DOT rule number let's say hundred.

72
00:04:55,110 --> 00:04:57,120
Okay so let us win this fight.

73
00:04:57,570 --> 00:05:03,120
What will happen at this line there will be an edit and because we are trying to change the rules.

74
00:05:03,140 --> 00:05:05,570
But okay so let us first read the file and see that it

75
00:05:10,250 --> 00:05:15,530
so would you indicate then that it why probably we didn't run this file.

76
00:05:15,950 --> 00:05:16,990
Yes.

77
00:05:17,330 --> 00:05:22,200
Okay now we will read this file again well guess what we get an error at this line.

78
00:05:22,260 --> 00:05:24,390
Now let us try to understand why we get an added

79
00:05:30,850 --> 00:05:31,600
so at this line.

80
00:05:31,600 --> 00:05:32,910
What will happen.

81
00:05:33,070 --> 00:05:36,970
Default constructed will be called default in the constructor.

82
00:05:37,690 --> 00:05:38,040
Okay.

83
00:05:38,080 --> 00:05:45,890
So default and built constructor will get called and what it will do age.

84
00:05:45,890 --> 00:05:49,830
Rule number both will be set to garbage value.

85
00:05:50,020 --> 00:05:52,480
So a general number both contingent garbage value.

86
00:05:52,510 --> 00:05:56,530
So this is to rent then that's when they both contain garbage values.

87
00:05:57,100 --> 00:05:57,660
Okay.

88
00:05:57,790 --> 00:05:58,810
Add this line.

89
00:05:58,900 --> 00:06:01,590
What I am trying to do I am making.

90
00:06:01,740 --> 00:06:06,390
I am overwriting the garbage value of the age to pen and add this line.

91
00:06:06,390 --> 00:06:07,790
I am overwriting.

92
00:06:08,020 --> 00:06:12,410
I am writing this garbage value and I am trying to make a hundred.

93
00:06:12,520 --> 00:06:14,110
But you cannot do this.

94
00:06:14,120 --> 00:06:14,800
Why.

95
00:06:14,870 --> 00:06:17,550
Because rule number is a constraint.

96
00:06:17,560 --> 00:06:23,260
If you see the glass if you show the glass we have make it in PJM constant since all lumber is in digit

97
00:06:23,260 --> 00:06:24,140
constant.

98
00:06:24,220 --> 00:06:26,680
Once it creates a value we cannot tolerate it.

99
00:06:27,100 --> 00:06:29,630
So here we cannot tolerate this garbage value.

100
00:06:29,740 --> 00:06:36,700
But if we will see we get an error at line number six why we go down a red line number six because what

101
00:06:36,700 --> 00:06:41,380
we are trying to do here is we are creating we are creating a rule number we are creating and digital

102
00:06:41,380 --> 00:06:43,760
constraint which will contain the garbage value.

103
00:06:43,900 --> 00:06:46,180
So compiler will not allow us to do this.

104
00:06:46,750 --> 00:06:54,560
So basically what compiler will say if these integer constant and this integer constant contains some

105
00:06:54,570 --> 00:06:59,470
garbage value then basically it's useless it's useless to make integer constraint.

106
00:06:59,530 --> 00:07:03,720
Okay so that's why we will get it at line number 6.

107
00:07:03,790 --> 00:07:05,910
We will also get in that red line number eight.

108
00:07:06,130 --> 00:07:09,340
But before line number it we will get that red line number six.

109
00:07:09,970 --> 00:07:14,830
Okay so it is amended to do initialize the rule number at the time of its creation at the time of memory

110
00:07:14,830 --> 00:07:15,610
allocation.

111
00:07:15,610 --> 00:07:22,150
Okay so the one way to correct that one for the one way to correct that record is what we will do we

112
00:07:22,150 --> 00:07:23,010
have to initialize.

113
00:07:23,020 --> 00:07:25,240
So let's make a hundred here now.

114
00:07:25,370 --> 00:07:26,620
There is a problem.

115
00:07:26,650 --> 00:07:27,850
So what is the problem.

116
00:07:27,850 --> 00:07:30,000
Suppose I have tends to rinse.

117
00:07:30,010 --> 00:07:31,190
Then what will happen.

118
00:07:31,270 --> 00:07:35,540
All that tends to advance will have the roll number is handed and they cannot change it.

119
00:07:35,620 --> 00:07:37,680
So obviously this is a wrong approach.

120
00:07:37,690 --> 00:07:39,660
This is a wrong method.

121
00:07:39,700 --> 00:07:41,760
Okay so what we should do.

122
00:07:41,890 --> 00:07:47,100
So where to initialize so that each object can have its different number of each object can have different

123
00:07:47,190 --> 00:07:47,830
number.

124
00:07:47,830 --> 00:07:53,500
So the answer is constructor y constructor because constructor is called for each object and construct

125
00:07:53,500 --> 00:07:55,180
will be called on live once.

126
00:07:55,270 --> 00:07:57,610
Okay so let us create a constructor

127
00:08:02,150 --> 00:08:03,130
so we will construct.

128
00:08:03,170 --> 00:08:06,010
We will create a better matrix constructor it will take.

129
00:08:06,030 --> 00:08:12,920
Rule number as input and then we will set rule number do.

130
00:08:13,830 --> 00:08:23,200
Okay now let us run this file see we are again getting an error so let us try to understand why we get

131
00:08:23,200 --> 00:08:23,640
in it at

132
00:08:30,000 --> 00:08:30,930
so when I write

133
00:08:34,060 --> 00:08:36,420
it a and in the next line.

134
00:08:36,610 --> 00:08:38,260
If I write a equals five.

135
00:08:38,800 --> 00:08:40,790
So at this line what will happen.

136
00:08:40,850 --> 00:08:45,360
So before a I am not writing and Deja before I am not writing Deja.

137
00:08:45,400 --> 00:08:46,540
So what does this mean.

138
00:08:46,540 --> 00:08:51,790
This means that is already created and the memory is already kicked into the memory which contains the

139
00:08:51,790 --> 00:08:55,850
garbage value and we are trying to override this garbage value.

140
00:08:56,060 --> 00:09:02,120
Okay now we see this line rhodium but it goes out we are not writing in Egypt before William but so

141
00:09:02,120 --> 00:09:07,270
that means that William has already been created in the memory and it contains the guide of base value.

142
00:09:07,280 --> 00:09:13,960
And here we are trying to put odd R in doodle lumber and lumber contains garbage value since all lumber

143
00:09:13,960 --> 00:09:21,200
is St. PJ constant we can not tolerate garbage failure without Okay so that's why we are getting added

144
00:09:21,280 --> 00:09:23,340
at this lane.

145
00:09:23,520 --> 00:09:30,570
Okay so what happened is as soon as we entered the constructor as soon as we each line number seven

146
00:09:31,680 --> 00:09:36,750
rule number is already created in the memory and it contains garbage value.

147
00:09:36,750 --> 00:09:38,250
So what is the solution.

148
00:09:38,280 --> 00:09:43,180
The solution is we have to initialize the rule number at the time of memory allocation.

149
00:09:43,230 --> 00:09:48,840
We cannot do it inside the constructor because as soon as we reach inside the constructor memories are

150
00:09:48,840 --> 00:09:52,840
allocated and garbage based Ray Lewis present at the memory location.

151
00:09:52,860 --> 00:09:58,020
Okay so what we can use here is there is something called initialization list

152
00:10:01,490 --> 00:10:04,850
initialization list can help us here.

153
00:10:04,850 --> 00:10:06,800
Okay so let's 1 again see.

154
00:10:06,830 --> 00:10:07,870
What is the problem.

155
00:10:07,880 --> 00:10:09,220
So the problem is very simple.

156
00:10:09,230 --> 00:10:16,250
As soon as we reach line number seven as soon as we reach inside the constructor the roll number this

157
00:10:16,250 --> 00:10:21,020
roll number property this roll number that a member has already been doing to the memory and it contains

158
00:10:21,110 --> 00:10:24,940
a garbage value and add line number seven and line number seven.

159
00:10:24,950 --> 00:10:30,190
We are trying to override this garbage value with ADD okay and we cannot do this.

160
00:10:30,190 --> 00:10:30,430
Why.

161
00:10:30,460 --> 00:10:32,710
Because a number is in beta constraint.

162
00:10:32,780 --> 00:10:35,000
We cannot change the values.

163
00:10:35,120 --> 00:10:37,490
We cannot change the value through a number.

164
00:10:37,490 --> 00:10:37,910
Okay.

165
00:10:38,030 --> 00:10:45,150
So the solution is initialization list so what initialization will do.

166
00:10:45,210 --> 00:10:49,680
It will initialize the constraint properties at the time of memory allocation.

167
00:10:49,680 --> 00:10:51,000
Now let's see this index

168
00:10:53,660 --> 00:10:56,050
so first of all this is wrong.

169
00:10:56,150 --> 00:11:02,240
Let us come into this code and this index for initialization list syntax for using initialization list

170
00:11:02,240 --> 00:11:03,620
is very simple.

171
00:11:03,680 --> 00:11:13,630
Put a column and then name of the name of the bat and we did the argument which is odd.

172
00:11:13,810 --> 00:11:14,080
Okay.

173
00:11:14,080 --> 00:11:14,800
And that's all.

174
00:11:15,270 --> 00:11:15,510
Okay.

175
00:11:15,520 --> 00:11:16,880
So let us win this fight.

176
00:11:18,320 --> 00:11:20,840
See now this time there is no edit.

177
00:11:20,960 --> 00:11:22,550
Okay so what is happening here is

178
00:11:27,530 --> 00:11:33,140
so I told you when we will reach line number seven rule number property is already being created in

179
00:11:33,140 --> 00:11:34,270
the memory.

180
00:11:34,490 --> 00:11:36,020
Now see line number six.

181
00:11:36,020 --> 00:11:37,160
So what will happen I like.

182
00:11:37,340 --> 00:11:39,460
So what will happen at line number six.

183
00:11:39,500 --> 00:11:45,000
We can assume that rule number is given memory at line number six.

184
00:11:45,020 --> 00:11:48,550
Rule number is given memory and add the line number six.

185
00:11:48,560 --> 00:11:50,480
We are writing this statement.

186
00:11:50,630 --> 00:11:53,480
So this rule number will contain R okay.

187
00:11:53,630 --> 00:11:59,710
So this way we can initialize our private properties week initialize have a constant private properties.

188
00:11:59,840 --> 00:12:07,900
So at this line we can say what is happening constant in integer rule number

189
00:12:11,400 --> 00:12:12,570
equals out.

190
00:12:12,630 --> 00:12:14,380
So this is the meaning of this line.

191
00:12:14,450 --> 00:12:15,100
Okay.

192
00:12:15,100 --> 00:12:21,450
Memories being allocated to General Lambert and the OT is initialized and this is and rule number and

193
00:12:21,450 --> 00:12:26,280
rule number of private properties initialized with that.

194
00:12:26,320 --> 00:12:28,510
Okay so this is the use of initialization list.

195
00:12:33,270 --> 00:12:38,730
Okay so what we can do here is it is not necessary to take an integer as input.

196
00:12:38,730 --> 00:12:43,530
We can also set the value as we can also write it like hundred but also.

197
00:12:43,530 --> 00:12:44,520
This is of no use.

198
00:12:44,520 --> 00:12:51,570
This is useless by useless because every object will have the roll number hundred okay every object

199
00:12:51,570 --> 00:12:53,740
will have rule number hundred.

200
00:12:53,760 --> 00:13:00,930
So obviously this is useless now what if I take two parameters hasn't put a general number so in total

201
00:13:00,930 --> 00:13:04,130
number and the second values and each.

202
00:13:04,170 --> 00:13:16,120
Okay so rule number are and then comma each is a okay so.

203
00:13:16,180 --> 00:13:21,260
So we should notice here is initialization list can also be used for normal variables.

204
00:13:21,270 --> 00:13:23,130
Normal integer variables.

205
00:13:23,130 --> 00:13:23,580
Okay.

206
00:13:23,640 --> 00:13:28,380
It can also be used for normal properties so it is not necessary.

207
00:13:28,530 --> 00:13:33,360
It is not compulsory that initialization list can only be used for constant data members.

208
00:13:33,450 --> 00:13:36,750
Okay initialization list can be used for normal data members.

209
00:13:37,340 --> 00:13:37,830
Okay.

210
00:13:38,010 --> 00:13:46,560
Now what will happen if I change the argument name to each so we have to write aged

211
00:13:50,390 --> 00:13:50,890
okay.

212
00:13:50,990 --> 00:13:51,860
So this is correct.

213
00:13:51,860 --> 00:13:56,210
There is no need to write this way because it is very clear.

214
00:13:57,680 --> 00:14:08,020
It is very clear here that this age means this at age and this age is the argument age so there is no

215
00:14:08,020 --> 00:14:09,180
confusion here.

216
00:14:09,190 --> 00:14:12,600
Everything is very clear so there is no need to write this here.

217
00:14:13,270 --> 00:14:17,010
Okay so there is no confusion since there is no confusion.

218
00:14:17,110 --> 00:14:24,320
We do not need to write this okay so one more case where the initialization list can be used is suppose

219
00:14:24,320 --> 00:14:29,450
we have a reference variable let us have a reference variable.

220
00:14:29,480 --> 00:14:40,030
Okay so offense variable X so this X is e.g. defense easy reference variable

221
00:14:45,860 --> 00:14:53,110
Okay so initialization list can also be used for reference variables to what we want is our aim is very

222
00:14:53,110 --> 00:14:53,530
simple

223
00:14:59,020 --> 00:14:59,830
so we've warned

224
00:15:03,590 --> 00:15:04,640
this.

225
00:15:04,730 --> 00:15:07,990
So this is our home okay.

226
00:15:08,360 --> 00:15:16,440
But it cannot write like this way because this H if you see here this age can be argument page.

227
00:15:16,610 --> 00:15:17,950
So there is a confusion here.

228
00:15:17,960 --> 00:15:26,470
Since there is confusion we have to write something like this this arrow each so at this line.

229
00:15:26,510 --> 00:15:29,730
There was confusion that age can be the argument age.

230
00:15:29,750 --> 00:15:32,960
So to avoid the confusion we will write this.

231
00:15:33,050 --> 00:15:33,290
Okay.

232
00:15:33,290 --> 00:15:35,450
So writing this is mandatory here.

233
00:15:36,470 --> 00:15:39,560
And I told you so I told you before.

234
00:15:39,560 --> 00:15:45,890
Just like the constraint variables reference variables have to be initialized at the time of its creation.

235
00:15:46,030 --> 00:15:54,480
Okay so it is mandatory that we have to use initialization list for reference variables so X and the

236
00:15:54,480 --> 00:15:56,610
value will be this arrow each

237
00:15:59,660 --> 00:16:00,800
okay.

238
00:16:00,920 --> 00:16:01,970
Now let us in this file

239
00:16:07,200 --> 00:16:12,450
now obviously as we write our own parameters constructor default constructor is not available to us

240
00:16:12,450 --> 00:16:12,890
anymore.

241
00:16:13,710 --> 00:16:16,440
So we have to use parameters constructor.

242
00:16:16,440 --> 00:16:20,410
So let's say that rule number is a hundred and let's say the easiest 10.

243
00:16:20,850 --> 00:16:21,520
Okay.

244
00:16:21,690 --> 00:16:23,340
So obviously this line will not work

245
00:16:26,150 --> 00:16:27,990
because when somebody is a constant property.

246
00:16:28,520 --> 00:16:33,430
Okay now let us on this file and they should be noted okay.

247
00:16:33,440 --> 00:16:34,710
So our code is running.

248
00:16:34,750 --> 00:16:37,420
There is no added.

249
00:16:37,640 --> 00:16:44,050
So what we learned in this session there's is something called initialization list.

250
00:16:46,520 --> 00:16:50,210
And what is the purpose of initialization list.

251
00:16:50,260 --> 00:16:52,350
The purpose is very easy.

252
00:16:52,560 --> 00:16:53,380
It initialize

253
00:16:56,550 --> 00:17:06,030
constraint properties constraint data members constraint properties and the defense's data member and

254
00:17:06,030 --> 00:17:09,250
reference properties at the time

255
00:17:12,220 --> 00:17:13,910
and their time of memory allocation

256
00:17:19,680 --> 00:17:20,630
okay.

257
00:17:20,700 --> 00:17:23,010
So I hope you have understood this video.

258
00:17:23,160 --> 00:17:23,620
Okay.

259
00:17:23,700 --> 00:17:24,110
Thank you.
