1
00:00:02,500 --> 00:00:03,190
Hi everyone.

2
00:00:03,190 --> 00:00:06,940
So in this reader we will discuss that topic template.

3
00:00:07,120 --> 00:00:08,780
So I have written some code.

4
00:00:09,010 --> 00:00:10,620
First I will explain you the code.

5
00:00:10,630 --> 00:00:15,860
So I have created this class glass beer so I have a glass beer.

6
00:00:15,970 --> 00:00:20,520
So it has two private properties X and Y and both are in danger.

7
00:00:21,500 --> 00:00:22,960
So then we have public.

8
00:00:23,050 --> 00:00:24,830
So we have set text function.

9
00:00:24,850 --> 00:00:28,880
It will take X and I don't assign the value of x to this X..

10
00:00:28,900 --> 00:00:29,560
Right.

11
00:00:29,560 --> 00:00:32,360
And similarly we have ghettos and setters.

12
00:00:32,410 --> 00:00:33,770
So it is returning the value fix.

13
00:00:33,850 --> 00:00:35,890
Similarly this is set to y function.

14
00:00:35,890 --> 00:00:37,210
It will set the value of y.

15
00:00:37,660 --> 00:00:41,610
And similarly we have got Y function and it is going to return the value of a.

16
00:00:41,650 --> 00:00:44,310
So we have simple getters and setters.

17
00:00:44,310 --> 00:00:48,070
Now what I want to do so I want to create this beer glass.

18
00:00:48,610 --> 00:00:54,250
So this pane of glass has the type in videos so x and y out of type integers.

19
00:00:54,250 --> 00:00:59,260
Now what I want to do I want to create a beer a glass of double.

20
00:00:59,320 --> 00:01:00,430
So how can we do that.

21
00:01:00,430 --> 00:01:05,890
So I will create the glass buildable and inside that X and Y both will readable.

22
00:01:05,890 --> 00:01:08,840
So I will write Double X and I will write to double y.

23
00:01:09,520 --> 00:01:14,980
Basically I will copy paste all this thing here and instead of integer what I will write I will write

24
00:01:14,980 --> 00:01:16,060
double.

25
00:01:16,060 --> 00:01:18,970
So I will replace integer here by double.

26
00:01:19,960 --> 00:01:25,150
Similarly I will replace integer by double here and so on.

27
00:01:25,150 --> 00:01:29,500
So I will replace integer by double and I will replace integer by double.

28
00:01:29,500 --> 00:01:37,680
So just copy paste this code and change in digit to double because now X and Y are of type double.

29
00:01:37,690 --> 00:01:41,840
So now we have a big class of integer and appear a class of double.

30
00:01:41,880 --> 00:01:47,000
Now later I want to create one more class B in a class of character.

31
00:01:47,050 --> 00:01:55,270
So again what I will lose so Class B are character and again so what we have to do we will copy paste

32
00:01:55,300 --> 00:01:57,880
this entire class.

33
00:01:57,880 --> 00:02:01,710
We will copy paste this entire class and it will be straight here.

34
00:02:01,930 --> 00:02:03,520
Copy and paste it here.

35
00:02:03,520 --> 00:02:08,450
The only change that we have to do is basically I will replace in Deja by character.

36
00:02:08,710 --> 00:02:10,690
Everything else will remain the same.

37
00:02:10,690 --> 00:02:16,630
So what we are doing we are copy pasting the class and we are just changing the data type so you can

38
00:02:16,630 --> 00:02:19,870
see there is so much repetition of code.

39
00:02:19,870 --> 00:02:23,770
What is the difference between this class and this class and this class.

40
00:02:23,800 --> 00:02:26,210
So the only difference is of data type.

41
00:02:26,230 --> 00:02:29,160
Everything else is same sometimes the data type is in danger.

42
00:02:29,180 --> 00:02:32,890
Sometimes the type is double and sometimes the data type is character.

43
00:02:33,130 --> 00:02:35,410
So what we can do so we can avoid this.

44
00:02:35,410 --> 00:02:38,110
Copy pasting thing we can use templates

45
00:02:40,980 --> 00:02:42,290
we can use templates.

46
00:02:42,540 --> 00:02:44,820
So how we can use templates.

47
00:02:44,820 --> 00:02:50,780
So what we will do so here what we are writing in Deja X so what I will write.

48
00:02:50,880 --> 00:02:52,460
I will write the x.

49
00:02:52,470 --> 00:02:57,760
Similarly I will write Tevi so how we will read this line.

50
00:02:57,760 --> 00:03:00,990
So the meaning of this line is X is a variable of type.

51
00:03:00,990 --> 00:03:03,990
The Y is a variable of type.

52
00:03:04,150 --> 00:03:08,590
So just like we used write in pediatrics so X is a variable of type in digit.

53
00:03:08,650 --> 00:03:17,740
So similarly X is a variable of type Integer sorry exit a variable of type B and similarly Y is a variable

54
00:03:17,740 --> 00:03:19,990
of type B and modesty.

55
00:03:19,990 --> 00:03:26,260
So t is our temporary Nina type these are temporary integer type.

56
00:03:26,350 --> 00:03:29,010
Now this the value of t can be in danger.

57
00:03:29,230 --> 00:03:31,510
The value of t can buildable.

58
00:03:31,510 --> 00:03:35,650
It can be corrected it can be flawed it can be boolean anything right.

59
00:03:35,890 --> 00:03:37,750
So the value of t can be anything.

60
00:03:37,750 --> 00:03:39,250
Now what we do.

61
00:03:39,310 --> 00:03:42,520
So first let us do this.

62
00:03:42,550 --> 00:03:49,300
So what we have to do instead of writing this Integer i will write these similarly instead of writing

63
00:03:49,300 --> 00:03:50,940
this Integer i will write T.

64
00:03:51,160 --> 00:03:55,800
And similarly I have to replace integer by d every year.

65
00:03:55,810 --> 00:04:04,080
So what I have to do so we will replace we will replace this integer Bayati everywhere.

66
00:04:04,090 --> 00:04:04,560
Right.

67
00:04:04,990 --> 00:04:06,310
So let's do that.

68
00:04:06,310 --> 00:04:08,050
So this this is not in danger.

69
00:04:08,050 --> 00:04:10,790
This is T V entertaining T.

70
00:04:11,620 --> 00:04:17,980
And similarly VI is of type T and Y is of type T right.

71
00:04:17,980 --> 00:04:20,950
So now we do not have integer WS character anywhere.

72
00:04:20,950 --> 00:04:24,970
We only have t so the compiler will say hey I don't know.

73
00:04:25,490 --> 00:04:25,850
Okay.

74
00:04:25,870 --> 00:04:32,230
So compiler will say you are using T every year but if you will compile this file the compiler will

75
00:04:32,590 --> 00:04:35,550
give us error that it does not know modesty.

76
00:04:35,560 --> 00:04:36,420
So what we have to do.

77
00:04:36,430 --> 00:04:42,960
So I have to write a line template type name.

78
00:04:43,660 --> 00:04:46,340
So we have to write this line above class.

79
00:04:46,450 --> 00:04:48,100
So write this line above class.

80
00:04:48,130 --> 00:04:49,020
So let's do that

81
00:04:52,970 --> 00:04:56,660
template type m. and D.

82
00:04:56,870 --> 00:05:01,900
So now the compiler will not give us error because it knows that modesty.

83
00:05:01,910 --> 00:05:03,760
So these are template.

84
00:05:03,830 --> 00:05:08,920
So now the compiler will not give us error if we will try to run this file.

85
00:05:09,170 --> 00:05:12,580
Now how we can create the object of this a class.

86
00:05:12,680 --> 00:05:18,330
So how to create object to a simple simpleton in Texas be happy right.

87
00:05:18,350 --> 00:05:20,810
So what is appear to be so pure B.

88
00:05:21,140 --> 00:05:27,370
So you have this X and Y X and Y and both out of type T.

89
00:05:27,530 --> 00:05:32,900
So what will happen you will get an added Violet because compiler doesn't know what is the value of

90
00:05:32,900 --> 00:05:33,650
t.

91
00:05:34,130 --> 00:05:36,770
So you cannot create objects like this.

92
00:05:36,770 --> 00:05:39,530
So how we will create object be it.

93
00:05:39,590 --> 00:05:41,780
So we have to give the value of t.

94
00:05:41,930 --> 00:05:47,260
So I want you to be integer so I will write parent and B.

95
00:05:47,380 --> 00:05:49,750
So what will happen to the effect of this line.

96
00:05:49,760 --> 00:05:52,740
So again you have X and Y and now what will happen.

97
00:05:52,740 --> 00:05:55,780
So T is going to be replaced by integer.

98
00:05:56,090 --> 00:05:58,550
So these will be replaced by integer here.

99
00:05:58,580 --> 00:06:00,520
So you can see so here.

100
00:06:00,600 --> 00:06:02,330
The value of p is in danger.

101
00:06:02,360 --> 00:06:08,290
So we are passing integer to be so P will be replaced by integer everywhere in the code.

102
00:06:08,300 --> 00:06:08,950
So this is T.

103
00:06:08,960 --> 00:06:10,280
Now this will become integer.

104
00:06:10,730 --> 00:06:14,740
Similarly DST it will become integer and everywhere in the code.

105
00:06:14,840 --> 00:06:17,120
So T is going to be replaced by integer.

106
00:06:17,540 --> 00:06:20,720
So similarly this will become integer and this will become a teacher.

107
00:06:20,720 --> 00:06:22,790
And this will become integer.

108
00:06:22,880 --> 00:06:29,810
So this is this index for creating the objects now and this will be the condition X and Y both are now

109
00:06:29,900 --> 00:06:30,830
integers.

110
00:06:30,830 --> 00:06:37,490
Now I want X and Y should be double and not integer so what I will lose so when we are creating the

111
00:06:37,550 --> 00:06:41,660
object I will simply pass double instead of integer.

112
00:06:41,690 --> 00:06:44,740
So if all right pair double lets it be too.

113
00:06:44,810 --> 00:06:45,740
So what will happen.

114
00:06:45,890 --> 00:06:48,820
The value of p is going to be replaced by a double.

115
00:06:48,830 --> 00:06:50,250
So everywhere in the code.

116
00:06:50,270 --> 00:06:55,430
So this is going to be replaced by the will this be replaced by the will this be replaced by level replaced

117
00:06:55,430 --> 00:06:58,020
by double replaced by double and replaced mutable.

118
00:06:58,040 --> 00:07:00,290
So now what will happen.

119
00:07:00,290 --> 00:07:11,440
So you are x and y both are now double double X double y so you can see with the help of template with

120
00:07:11,440 --> 00:07:17,770
the help of template you do not need to copy paste the class you just need to pass that data type if

121
00:07:17,920 --> 00:07:24,310
possible then you will have x and y both double if you can also pass character you can pass anything

122
00:07:24,640 --> 00:07:32,500
so t can be anything you can pass character B three so it will happen X and Y are now characters.

123
00:07:32,500 --> 00:07:34,330
So the logic is very simple.

124
00:07:34,660 --> 00:07:38,190
The value that you are passing the value that we are passing.

125
00:07:38,230 --> 00:07:42,510
So T is going to be replaced by that value everywhere in the world.

126
00:07:42,580 --> 00:07:49,520
So let's write the code and let's check so let's write the code be it.

127
00:07:49,520 --> 00:07:51,370
Now these should be replaced by integer.

128
00:07:51,390 --> 00:07:57,680
So I am passing integer B1 and now it does give the value of x and y.

129
00:07:57,840 --> 00:07:59,430
So we'll call the function.

130
00:07:59,520 --> 00:08:04,740
So even dot syntax let's say the value is 1.

131
00:08:05,820 --> 00:08:12,570
Similarly even dot sent away the value is 2.

132
00:08:13,050 --> 00:08:23,330
And now let us also print the value so see out we will not get X and we will also print the value of

133
00:08:23,330 --> 00:08:23,550
life.

134
00:08:23,570 --> 00:08:25,520
So we cannot get away

135
00:08:31,870 --> 00:08:35,220
and now let's create a bit of a double.

136
00:08:35,220 --> 00:08:43,290
So I am creating a bit of a double letter the name is B2 so B2 dot surtax.

137
00:08:43,390 --> 00:08:46,120
Let's say one point seventy.

138
00:08:46,120 --> 00:08:55,510
Similarly we do that certainly let's say the value is to point to 1 and again it will also bring devalue.

139
00:08:55,580 --> 00:08:58,130
So you don't get X

140
00:09:02,520 --> 00:09:07,230
beauty art getaway.

141
00:09:07,570 --> 00:09:08,950
So what should be our output.

142
00:09:09,690 --> 00:09:11,380
So it's very simple.

143
00:09:11,380 --> 00:09:19,150
So you're creating a pair of integers so this is P1 and inside P1 both X and Y are of type integers

144
00:09:22,590 --> 00:09:26,780
then you're calling the function statics so set takes the value of these integer.

145
00:09:27,330 --> 00:09:29,310
So you are a passing integer 1 and 2.

146
00:09:29,310 --> 00:09:29,910
Right.

147
00:09:29,940 --> 00:09:36,120
So the value of x is when the valley of y is to the value of Y is true.

148
00:09:36,210 --> 00:09:37,990
And then you're calling the Gattex function.

149
00:09:38,040 --> 00:09:39,820
So get x.

150
00:09:39,900 --> 00:09:41,380
This is in danger.

151
00:09:41,670 --> 00:09:46,340
And similarly this is integer so it will return the value of x and then the value of y.

152
00:09:46,350 --> 00:09:48,580
So at this line my output should be 1.

153
00:09:48,600 --> 00:09:49,680
Then we have space.

154
00:09:49,710 --> 00:09:50,950
So 1 space 2.

155
00:09:51,000 --> 00:09:53,660
And similarly for this P2 what will happen.

156
00:09:53,670 --> 00:09:54,680
We have discussed already.

157
00:09:54,690 --> 00:10:00,660
So it will be double X and double y and everywhere in the code.

158
00:10:00,660 --> 00:10:04,790
So this deal is going to be replaced by double again.

159
00:10:04,930 --> 00:10:07,790
This tree is replaced by the will this be replaced by double.

160
00:10:07,800 --> 00:10:10,490
And also this tree is replaced by level.

161
00:10:10,500 --> 00:10:12,030
So this is double expendable right.

162
00:10:12,870 --> 00:10:14,850
So the logic is very simple.

163
00:10:15,020 --> 00:10:18,090
He is going to be replaced by double everywhere inside the code.

164
00:10:18,180 --> 00:10:21,550
And for this these replaced by integer everywhere.

165
00:10:21,630 --> 00:10:22,690
You have used the.

166
00:10:23,130 --> 00:10:25,030
It will be replaced by integer inside the code.

167
00:10:25,050 --> 00:10:27,540
Then you are calling the next function and get way function.

168
00:10:27,540 --> 00:10:32,880
So the value of X was one point seventy and the value of why was to point to one.

169
00:10:32,880 --> 00:10:37,670
So again your output should be one point seventy three then a space then two point two one.

170
00:10:37,680 --> 00:10:41,340
So let's see where that our logic is correct or not

171
00:10:44,680 --> 00:10:45,760
let's add in this file

172
00:10:49,130 --> 00:10:50,520
so you can see the output.

173
00:10:50,990 --> 00:10:54,050
I have one end to the value of x and y.

174
00:10:54,500 --> 00:10:59,000
And again I have the value of x and y one point seventy three and two point two one.

175
00:10:59,030 --> 00:11:01,250
So that's how it is working.

176
00:11:01,290 --> 00:11:09,080
Now similarly what you can do you can create you can also create pair of characters.

177
00:11:09,110 --> 00:11:15,770
So what you have to do be it off you will positively type your type character and be three.

178
00:11:15,810 --> 00:11:22,030
So in this case what will happen to be three so be three as X and Y.

179
00:11:22,430 --> 00:11:24,970
And this time the D replaced by characters.

180
00:11:24,980 --> 00:11:27,330
So this is character X and character y.

181
00:11:27,410 --> 00:11:33,440
And similarly you can set the value of x you can set the value of a you can call get X function and

182
00:11:33,440 --> 00:11:37,690
get way function and you can print the values of x and y.

183
00:11:37,820 --> 00:11:39,520
Now what I want.

184
00:11:39,650 --> 00:11:41,760
So I have two variables right.

185
00:11:41,780 --> 00:11:44,380
I have X and I m y.

186
00:11:45,210 --> 00:11:50,550
Now I want my X should be in danger and my Y should be double.

187
00:11:52,460 --> 00:11:59,630
So currently what do we have so I am writing if I will write B it often digits then both X and Y will

188
00:11:59,630 --> 00:12:07,360
become integer if I will pass if I will create objects like this pair of double notes.

189
00:12:07,380 --> 00:12:09,200
This is P1 and this is P2.

190
00:12:09,320 --> 00:12:13,390
So if I will pass double then both X and Y will become double.

191
00:12:14,780 --> 00:12:15,780
But what do I want.

192
00:12:15,800 --> 00:12:19,970
I want my X should be integer and my Y should be double.

193
00:12:20,300 --> 00:12:22,580
So how we can do that.

194
00:12:22,580 --> 00:12:24,110
So again it's very simple.

195
00:12:24,470 --> 00:12:26,470
So what we will do.

196
00:12:26,930 --> 00:12:29,610
So here we are using only one embedded in our day.

197
00:12:29,660 --> 00:12:32,200
What we will do we will use one model type.

198
00:12:32,270 --> 00:12:43,020
So I will write template X and sorry D X and v y so X is of type D Y is of type V and then will create

199
00:12:43,040 --> 00:12:45,250
object so will pass the value of the envy.

200
00:12:45,260 --> 00:12:48,050
So I will write like this year end and double

201
00:12:50,680 --> 00:12:51,630
B3.

202
00:12:51,750 --> 00:12:54,730
So what will happen this V.

203
00:12:54,760 --> 00:13:00,480
So this is going to be replaced by integer and V is going to be replaced by W.

204
00:13:00,510 --> 00:13:03,930
So let me write the code so that you will be able to understand to properly write

205
00:13:07,320 --> 00:13:13,980
instead of the X. We will use one more time Brady type little name is V so compiler doesn't know what

206
00:13:13,980 --> 00:13:17,730
is V so what do you do you will add this here.

207
00:13:17,730 --> 00:13:22,350
So type name is we know okay.

208
00:13:22,350 --> 00:13:32,310
So we have to type names the envy we are using to compute D and V so X is of type B VI is of type v

209
00:13:32,880 --> 00:13:33,960
perfect.

210
00:13:33,960 --> 00:13:35,810
So what do we have here.

211
00:13:35,820 --> 00:13:47,400
Yes X is of type T I will return t now VI is of type V and similarly for get Y Y is of type V so what

212
00:13:47,400 --> 00:13:48,630
I'm doing here.

213
00:13:48,960 --> 00:13:54,350
So X is of type T VI is of type V so x type T.

214
00:13:54,360 --> 00:13:58,910
And similarly when are calling get text function we are turning x of type T.

215
00:13:58,980 --> 00:14:05,520
So similarly VI is of type V and here the return type is v simple and also we have updated.

216
00:14:05,820 --> 00:14:08,540
So compiler will say Ah I don't know what s v.

217
00:14:08,610 --> 00:14:14,110
So I have added here type name V so now when we create the object.

218
00:14:14,110 --> 00:14:19,980
So I have to create objects like this why because I have to pass the value of B as well as the value

219
00:14:19,980 --> 00:14:20,610
of B.

220
00:14:20,670 --> 00:14:23,080
So first the value of t should be given.

221
00:14:23,090 --> 00:14:27,720
So the value of t is integer then you have to give the value of V.

222
00:14:27,750 --> 00:14:29,040
So this is V.

223
00:14:29,130 --> 00:14:31,370
So it is just like function.

224
00:14:31,530 --> 00:14:36,750
So in function function takes some arguments and when you want to call this function you have to pass

225
00:14:36,780 --> 00:14:42,210
the arguments and then the arguments will be passed in order right.

226
00:14:42,210 --> 00:14:43,870
So again we have two arguments here.

227
00:14:43,870 --> 00:14:44,910
The end V.

228
00:14:45,060 --> 00:14:51,020
So we are passing the value of first argument which is integer and the value of second argument is double.

229
00:14:51,210 --> 00:14:53,570
So let's do that.

230
00:14:53,610 --> 00:14:57,800
So this is this will not work because you have to pass to a lose.

231
00:14:58,980 --> 00:15:03,210
So combined out everything so you will write like this.

232
00:15:03,210 --> 00:15:03,930
Beer.

233
00:15:04,320 --> 00:15:13,000
What is the first value the value of x is in danger and the value of V is double.

234
00:15:13,050 --> 00:15:15,360
Let's see the name is B1.

235
00:15:15,360 --> 00:15:23,490
So what will happen now so B1 have two values X and Y.

236
00:15:23,490 --> 00:15:29,460
Now y x is of type in digit axis of type Integer and Y is of type double

237
00:15:33,320 --> 00:15:34,670
now similarly where do we look.

238
00:15:34,670 --> 00:15:39,950
We will call these tactics functions that way function and get taxing get way function.

239
00:15:39,950 --> 00:15:48,130
So let's do that so after creating the object so let's call the functions it takes and set way so be

240
00:15:48,130 --> 00:15:52,570
rendered set x so x is in D a right.

241
00:15:52,990 --> 00:15:59,270
So for example I am passing one point seventy and let's call do I.

242
00:15:59,490 --> 00:16:07,050
So we went out said wait and let's say I am passing one point seventy.

243
00:16:07,120 --> 00:16:11,580
Let us call the function get X and get way to devalue to get X

244
00:16:14,500 --> 00:16:15,940
and be rendered get to a

245
00:16:19,150 --> 00:16:22,830
So what should be on output so be when right.

246
00:16:22,840 --> 00:16:26,970
So we have between X and Y X was B.

247
00:16:27,010 --> 00:16:29,380
So initially we had the X and we y.

248
00:16:29,440 --> 00:16:30,850
So the value of these integer.

249
00:16:30,880 --> 00:16:34,000
So this is in danger and the value of V is double.

250
00:16:34,150 --> 00:16:35,650
So this is double.

251
00:16:35,650 --> 00:16:41,560
So we have integer X and double y now settings.

252
00:16:41,600 --> 00:16:42,880
So this should be in D right.

253
00:16:42,890 --> 00:16:48,240
But I am passing one point seventy so what will happen this one point seventy has to be type cluster.

254
00:16:48,260 --> 00:16:55,670
So implicit type casting will take place and I will store only 1 because X is of type Integer and Vi

255
00:16:55,670 --> 00:16:56,510
is of type double.

256
00:16:56,510 --> 00:16:57,260
So one point.

257
00:16:57,320 --> 00:17:02,120
So why the value of y you would be one point seventy three because values of type double since x is

258
00:17:02,120 --> 00:17:02,900
of type in danger.

259
00:17:02,930 --> 00:17:09,140
So implicit typecasting will take place and the value of x is 1 and the value of y is one point seventy

260
00:17:10,040 --> 00:17:15,670
and then I am bringing the value of x so one should be my one should be printed here and one point seventy

261
00:17:15,680 --> 00:17:17,030
should be printed here.

262
00:17:17,030 --> 00:17:20,080
So let's see the output should be one and one point seventy

263
00:17:25,550 --> 00:17:31,630
so you can see the value of x is 1 and the value of y is one point seventy.

264
00:17:31,730 --> 00:17:37,940
So implicit typecasting is taking place in case of X because X is of type Integer and you are passing

265
00:17:37,940 --> 00:17:41,660
the value w I think there should be warning here.

266
00:17:41,660 --> 00:17:45,290
Okay so there is no warning but if you're using a good compiler.

267
00:17:45,350 --> 00:17:47,400
So what you can get.

268
00:17:47,480 --> 00:17:52,700
So if you are using a good compiler sometimes you will get a warning that implicit type casting is taking

269
00:17:52,700 --> 00:17:53,690
place.

270
00:17:53,720 --> 00:17:55,620
So now what else can we do.

271
00:17:55,640 --> 00:17:59,980
So now what I want to do so I want to create a triplet.

272
00:18:00,710 --> 00:18:03,470
So I want to create a triplet

273
00:18:06,040 --> 00:18:13,750
and inside this triplet so it is obvious I will have three values let's say x y and z axis of Type D

274
00:18:13,870 --> 00:18:22,580
Y is of type V and Z is of type W and obviously I will have here a template.

275
00:18:22,900 --> 00:18:31,490
So type name type empty called my type name type name V and type name W.

276
00:18:31,840 --> 00:18:34,840
So if I want to create a template.

277
00:18:34,930 --> 00:18:41,860
So these these are the three values the three variable x y and z so X is of type T values of type V

278
00:18:41,860 --> 00:18:43,330
and Z is of type W.

279
00:18:43,330 --> 00:18:46,530
And here we have defined what our TV and W.

280
00:18:46,660 --> 00:18:50,050
So how do we create the object of this triplet class.

281
00:18:50,050 --> 00:18:54,580
So for creating the object you will write something like this triplet you have to pass three values

282
00:18:54,580 --> 00:18:55,730
the value of B.

283
00:18:55,840 --> 00:19:01,070
So for example D integer let's say vs also integer and later the Blues also integer.

284
00:19:01,390 --> 00:19:07,270
And even so that is how you will create the object of triplet class.

285
00:19:07,420 --> 00:19:09,420
So what will be the effect of this line.

286
00:19:09,490 --> 00:19:15,420
So the effect is very simple X Y and Z all these three will be integer.

287
00:19:15,670 --> 00:19:21,500
Now here also if you want X and Y both should be in danger then instead of passing and comma that what

288
00:19:21,520 --> 00:19:25,210
you can do you can write in combined B1.

289
00:19:25,210 --> 00:19:26,320
So what will be the effect.

290
00:19:26,320 --> 00:19:31,290
So both X and Y both X and Y will be integer.

291
00:19:31,360 --> 00:19:32,020
In this case.

292
00:19:32,620 --> 00:19:36,930
So this is the problem statement that you want to create a tablet.

293
00:19:37,210 --> 00:19:41,300
So the problem statement is create a template with three values X Y and Z.

294
00:19:41,470 --> 00:19:44,760
And these are the B dare type TV and blue.

295
00:19:44,980 --> 00:19:46,690
But the problem is a little bit different.

296
00:19:46,690 --> 00:19:49,240
You cannot create this class.

297
00:19:49,240 --> 00:19:51,350
You have to use peer class.

298
00:19:51,490 --> 00:19:55,150
You have to use spin class to write this triplet class.

299
00:19:55,150 --> 00:19:59,440
So what I want to say here is I do not want to create a new class.

300
00:19:59,830 --> 00:20:05,600
I want to use Peri class to have three values I am a British myself.

301
00:20:05,830 --> 00:20:08,110
I do not want to create this triplet class.

302
00:20:08,920 --> 00:20:14,570
I want to use a class in such a way that this bitter class can act as a prepared class.

303
00:20:14,620 --> 00:20:21,070
So I want this of class to act as if it is a prepared class.

304
00:20:21,070 --> 00:20:24,520
So let's see how we can do that.

305
00:20:24,520 --> 00:20:31,580
So what will happen if you will write fear and mind and B.

306
00:20:31,990 --> 00:20:33,520
So what will happen.

307
00:20:33,520 --> 00:20:38,210
So I have two values x and y.

308
00:20:38,380 --> 00:20:45,250
This is X and this is why so X is of type Integer so this is in digit and Y is of type Integer.

309
00:20:45,280 --> 00:20:48,380
Now what will happen if I write like this bit.

310
00:20:48,460 --> 00:20:55,430
So this was your t and this was your V now what will happen if I write like this.

311
00:20:57,180 --> 00:21:05,210
Bit of deja combined Deja coma and Deja B.

312
00:21:05,430 --> 00:21:06,510
So what will happen.

313
00:21:06,510 --> 00:21:09,660
So we will take the help of this simple example.

314
00:21:09,660 --> 00:21:13,980
So the first value is deep and the second value is we.

315
00:21:14,010 --> 00:21:16,290
So this is the first value.

316
00:21:16,600 --> 00:21:20,590
So this is deep and this is the second value.

317
00:21:20,590 --> 00:21:29,650
So this is the So let's draw the diagram so this big B has two values X and Y.

318
00:21:30,570 --> 00:21:33,310
So this is X and this is why what is why.

319
00:21:33,330 --> 00:21:34,650
Why is it simply in danger.

320
00:21:34,740 --> 00:21:36,480
So why is it simply integer.

321
00:21:36,600 --> 00:21:37,520
What is x.

322
00:21:38,280 --> 00:21:46,980
So X is of type B and D appear so again it is appeared and since it does appear it will have two values

323
00:21:47,190 --> 00:21:49,620
X and Y.

324
00:21:49,650 --> 00:21:52,040
Now what is the value of this X.

325
00:21:52,050 --> 00:21:53,480
So this is in Egypt.

326
00:21:53,670 --> 00:21:57,770
This is integer and what is the value of y.

327
00:21:57,900 --> 00:22:01,560
So why is also integer.

328
00:22:01,560 --> 00:22:09,030
So the effect of this line is basically your peer class will look no object will look something like

329
00:22:09,030 --> 00:22:09,950
this.

330
00:22:09,990 --> 00:22:13,010
So yes what you can do so what is T.

331
00:22:13,020 --> 00:22:15,810
These are temporary data type and you can replace T.

332
00:22:15,840 --> 00:22:18,640
Yes you can replace T with objects like this.

333
00:22:18,660 --> 00:22:21,180
So this is nothing it is just idea type right.

334
00:22:23,630 --> 00:22:27,910
So you can replace T with something like this user defined your type.

335
00:22:27,950 --> 00:22:29,690
So this is user defined their type.

336
00:22:29,690 --> 00:22:32,820
So you can replace T with the user defined your type also.

337
00:22:32,900 --> 00:22:34,760
Now my question is what I want to do.

338
00:22:35,630 --> 00:22:37,090
So now we have three values right.

339
00:22:37,100 --> 00:22:38,030
So this is the first one.

340
00:22:38,060 --> 00:22:42,900
This is the second value and this is the third value so I am able to store three values.

341
00:22:43,160 --> 00:22:46,250
Now what I want to do I want to write 10 here.

342
00:22:46,250 --> 00:22:47,320
I want to write 10 here.

343
00:22:47,330 --> 00:22:50,840
I want to write 20 here and I want to write party here.

344
00:22:50,840 --> 00:22:52,660
So how can we do that.

345
00:22:52,700 --> 00:22:55,880
So the object the name of the object is B.

346
00:22:56,250 --> 00:23:01,790
So putting party here is very simple what I will do so I will write like this.

347
00:23:01,840 --> 00:23:07,130
B DOT said we beat out Saturday and I will pass the value today.

348
00:23:07,600 --> 00:23:09,910
So today will be placed here.

349
00:23:09,940 --> 00:23:14,770
Now the question is how to put pen here and how to put 20 here.

350
00:23:14,770 --> 00:23:21,640
So what I will do B Dot said X so this is X right.

351
00:23:21,640 --> 00:23:26,020
So I am calling the function settings now set X function what it takes as input.

352
00:23:26,020 --> 00:23:29,990
So if you can see where is set x rays yes.

353
00:23:30,160 --> 00:23:32,110
So this is a static function.

354
00:23:32,110 --> 00:23:34,700
It takes input D and what is P.

355
00:23:34,840 --> 00:23:41,650
These appear these appear so you cannot give values Ten Commandments No this is wrong.

356
00:23:41,650 --> 00:23:45,620
Why this is wrong because now do the type is.

357
00:23:46,210 --> 00:23:47,970
So you have to pass a appear.

358
00:23:48,040 --> 00:23:49,620
You have to pass up period.

359
00:23:49,630 --> 00:23:51,800
So what I will do I will create one more bit.

360
00:23:52,000 --> 00:23:55,070
So let's create one more beer.

361
00:23:55,720 --> 00:24:00,030
So beer and combined went into combined.

362
00:24:00,060 --> 00:24:05,510
Because I have to put pen into India and let's say the name is before.

363
00:24:05,560 --> 00:24:14,250
Now before that surtax has been and before that Saturday is 20.

364
00:24:14,260 --> 00:24:15,310
So what is before.

365
00:24:15,330 --> 00:24:20,470
So P four has two values X and Y X and Y.

366
00:24:20,910 --> 00:24:25,820
X is of type in Deja VI is of type Integer we are calling the functions are text to the value of 10.

367
00:24:25,830 --> 00:24:29,700
So then the liberals today are calling the value you are calling the function set way and they will

368
00:24:29,690 --> 00:24:34,860
use 20 so twenty will replaced here and now let's rewrite dysfunction.

369
00:24:34,860 --> 00:24:41,110
So be DOT said X so this is X and what it takes.

370
00:24:41,200 --> 00:24:46,300
So it takes a bit as input and we will pass this bill before.

371
00:24:46,750 --> 00:24:50,320
So I will pass before here.

372
00:24:50,320 --> 00:24:56,500
So I am passing before here and what is before and so before is this simple P an X and Y.

373
00:24:56,560 --> 00:24:57,220
So what will happen.

374
00:24:57,220 --> 00:24:59,860
These two values 10 and 20 will get copied.

375
00:24:59,980 --> 00:25:03,430
So 10 will be placed here and twenty will be placed here.

376
00:25:03,670 --> 00:25:08,010
So that's how we will be able to put 10 and 20 here.

377
00:25:08,060 --> 00:25:13,800
Now if you want to print the value so I want to print the value.

378
00:25:13,840 --> 00:25:19,490
So in order to print the value so be dot let's say you want to print 30.

379
00:25:19,500 --> 00:25:20,440
So it is very simple.

380
00:25:20,440 --> 00:25:25,430
You will simply call the function get Y and Gateway function will return.

381
00:25:25,470 --> 00:25:29,000
We saw Gateway function earlier than we and we is in danger.

382
00:25:29,030 --> 00:25:31,000
So this is v v as in digit.

383
00:25:31,030 --> 00:25:34,100
So the output will be then sorry output and retard.

384
00:25:34,180 --> 00:25:37,900
Now I want to print 10 and 20 also.

385
00:25:37,900 --> 00:25:43,030
So if I will call the function and get X if I will call the function get x.

386
00:25:43,050 --> 00:25:49,650
So this is good check function it will return to and modesty so D is a bit off and Deja common.

387
00:25:49,980 --> 00:25:55,030
So this thing is going to return me a bit.

388
00:25:55,210 --> 00:25:59,930
So this beer will be returned to me and I want to print the value of x.

389
00:25:59,970 --> 00:26:06,240
So what I will do I will write get X so the output will return.

390
00:26:06,420 --> 00:26:15,680
And similarly if I want to print divide I lose a b dart get X so get X it will return me appeared so

391
00:26:15,680 --> 00:26:21,500
it is going to return a bit and I want to end of that pier I want to access the value of y so I will

392
00:26:21,500 --> 00:26:23,470
call get Y.

393
00:26:24,080 --> 00:26:25,790
So the output will be n here.

394
00:26:26,720 --> 00:26:29,480
Okay so that's how everything is working.

395
00:26:29,480 --> 00:26:33,290
So now let's command out everything and let's write the code for this one

396
00:26:38,170 --> 00:26:39,760
so let's come and don't have anything

397
00:26:44,950 --> 00:26:48,490
and let us it is the screen also we will write the code from fresh

398
00:26:53,320 --> 00:26:53,640
okay.

399
00:26:53,650 --> 00:26:54,810
So I want to use.

400
00:26:54,830 --> 00:27:01,300
So the problem statement was you want to use PID so that it can behave as a template by triplet behaving

401
00:27:01,300 --> 00:27:04,330
means you guys you will be able to store three values.

402
00:27:04,330 --> 00:27:07,540
So with the help of a glass you against all three values like this.

403
00:27:07,540 --> 00:27:07,980
So.

404
00:27:08,050 --> 00:27:08,420
Beer.

405
00:27:08,420 --> 00:27:09,410
Beer and.

406
00:27:10,460 --> 00:27:12,580
And so this is the value of the.

407
00:27:12,610 --> 00:27:14,690
And this is the value of me.

408
00:27:14,830 --> 00:27:20,710
Let's say the name of the object this be and let us set the value of y first.

409
00:27:20,830 --> 00:27:25,080
So certainly the value was tardy as decided.

410
00:27:27,640 --> 00:27:31,390
And now it will do so we have to create a beer first.

411
00:27:31,420 --> 00:27:33,670
So let's give it one more beer.

412
00:27:33,670 --> 00:27:51,110
So beer in Deja in Deja let's call it temp and temp dart sceptics the value is 10 so temp.

413
00:27:51,540 --> 00:27:56,800
Not certainly the value is 20.

414
00:27:56,900 --> 00:27:58,340
And what do we do now.

415
00:27:58,460 --> 00:28:09,290
So be not stocks this set X function it will take as input and I am passing temp so now my beard is

416
00:28:09,290 --> 00:28:09,890
ready.

417
00:28:09,890 --> 00:28:12,530
So what I have to do I have to print the values now.

418
00:28:12,950 --> 00:28:17,670
So let's print the values so let's see out

419
00:28:20,410 --> 00:28:24,330
be dart get x.

420
00:28:24,610 --> 00:28:30,070
So it will return me up here and of that bet I want to access the x value.

421
00:28:30,070 --> 00:28:32,610
So print x God get x.

422
00:28:33,010 --> 00:28:33,700
Similarly

423
00:28:37,180 --> 00:28:40,640
again call B dot get x.

424
00:28:40,660 --> 00:28:45,100
So it is going to return me a bit and of that bit I want to exist.

425
00:28:45,100 --> 00:28:52,830
The y values so get Y and now and again do so we can print 30.

426
00:28:52,830 --> 00:28:54,930
So for printing that 30 what will I do.

427
00:28:54,930 --> 00:28:56,460
So be dot get Y

428
00:29:01,410 --> 00:29:07,740
Okay so let's first run of a code and let us first run this file and then we will brighten what is happening

429
00:29:11,540 --> 00:29:16,610
so you can see the output is 10 20 and 30.

430
00:29:16,640 --> 00:29:18,850
So this is all that we have wanted.

431
00:29:18,860 --> 00:29:21,910
So this this is the correct output 10 20 and 30.

432
00:29:21,980 --> 00:29:27,540
And now let's see how everything is working let's write a novel code.

433
00:29:27,970 --> 00:29:29,430
So yes.

434
00:29:29,500 --> 00:29:30,750
So this is B.

435
00:29:31,000 --> 00:29:34,790
Okay so create an object.

436
00:29:34,790 --> 00:29:37,240
So this B has two things X and Y.

437
00:29:37,760 --> 00:29:41,760
So this is your X and this is your way.

438
00:29:41,930 --> 00:29:46,200
Okay so X is this appeared.

439
00:29:46,400 --> 00:29:51,910
So if you remember we have d x and v vi so VI is in danger.

440
00:29:51,920 --> 00:29:58,820
So this is simply deja and X is B and D again appeared so again appear.

441
00:29:58,820 --> 00:30:03,960
That means you will have again X and Y.

442
00:30:04,220 --> 00:30:08,120
So this is your x and this is your right.

443
00:30:08,440 --> 00:30:10,850
And both out of indigent integer and Deja.

444
00:30:10,900 --> 00:30:15,190
So this is also in Egypt and this is also integer fine.

445
00:30:15,490 --> 00:30:17,470
So be that set the value function.

446
00:30:17,470 --> 00:30:20,360
So this is set to y you are passing today.

447
00:30:20,380 --> 00:30:24,230
So what will happen 10 will be present here.

448
00:30:24,250 --> 00:30:24,900
Simple.

449
00:30:25,240 --> 00:30:33,360
You are creating at the appeared temp so let's create and then better temp so this temp will have x

450
00:30:33,360 --> 00:30:33,690
and y.

451
00:30:33,720 --> 00:30:39,060
So this is temp and this is B.

452
00:30:39,190 --> 00:30:41,710
So this is temp right in deja A.J..

453
00:30:41,740 --> 00:30:46,870
OK so this is in danger and this is all turned Deja now.

454
00:30:46,940 --> 00:30:53,650
Settings you are passing ten so ten was replaced here said Dwight you are passing 20 so now 20 is presented

455
00:30:54,610 --> 00:31:00,680
so you are calling B dot site X. So this is B This was b so B Dart said x.

456
00:31:00,760 --> 00:31:08,040
So that means this thing and this thing requires a b it as input it requires Hep B it is input and you

457
00:31:08,040 --> 00:31:16,020
are passing temp so temp is up here so you are passing this be a hard copy assignment operator will

458
00:31:16,020 --> 00:31:16,680
be called here

459
00:31:19,640 --> 00:31:26,180
okay so internally copy assignment operator will be called and these two values 10 and 20 will be copied.

460
00:31:26,330 --> 00:31:29,840
So 10 will be copied here and 20 will be copied here.

461
00:31:29,840 --> 00:31:34,940
So internally we are calling the copy assignment operator to copy these two values 10 and 20.

462
00:31:34,970 --> 00:31:42,650
So now 10 is presented and 20 is present here then you are calling B dot get X so b don't get X it will

463
00:31:42,650 --> 00:31:43,700
return you appear.

464
00:31:43,820 --> 00:31:50,510
So this part is going to return you appear and of that page you want to X is the value x so get X you

465
00:31:50,510 --> 00:31:53,170
will call you and get in.

466
00:31:53,330 --> 00:31:56,930
So that's how N is getting printed here then we have space.

467
00:31:57,020 --> 00:31:58,940
So again be dot and get x.

468
00:31:59,000 --> 00:32:02,890
So this is X again you will get up here.

469
00:32:03,120 --> 00:32:04,880
So again you will get up here.

470
00:32:04,910 --> 00:32:10,590
So this is a bit and then you are calling get Y functions so this is 20.

471
00:32:10,590 --> 00:32:14,280
So that's how it guarantees getting printed here and this is very simple.

472
00:32:14,490 --> 00:32:15,320
Bedard get.

473
00:32:15,360 --> 00:32:17,240
So be dot get Y.

474
00:32:17,310 --> 00:32:19,260
So today will be printed here.

475
00:32:19,350 --> 00:32:24,040
So that's how your output becomes so 10 then 20 and then 30.

476
00:32:24,060 --> 00:32:27,240
So then then space 2010 spaced happy.

477
00:32:27,360 --> 00:32:30,580
So that's how everything is working.

478
00:32:30,630 --> 00:32:42,360
So now for example if you want to create a triplet such that the first value is in digit the second

479
00:32:42,360 --> 00:32:50,620
value let's say is double and that total value is related to so you want to create a place like this.

480
00:32:50,620 --> 00:32:52,210
So what will be this index

481
00:32:55,670 --> 00:33:05,660
now if you want you can pass this bit as b or you can pass this bit as we so let's hear.

482
00:33:05,780 --> 00:33:09,050
So the first rule losing digits I am passing and beach ahead.

483
00:33:09,180 --> 00:33:11,630
Now the second value I have to pass.

484
00:33:11,900 --> 00:33:14,800
So I will look club these two for example I am loving these two.

485
00:33:14,810 --> 00:33:16,640
So this too will become a beer.

486
00:33:16,650 --> 00:33:23,220
So beer what is the first value double and what is the second value character.

487
00:33:23,600 --> 00:33:23,960
Right.

488
00:33:23,960 --> 00:33:25,040
Simple.

489
00:33:25,070 --> 00:33:26,830
And this is B.

490
00:33:26,960 --> 00:33:36,390
So what will happen where will the effect of this line again you will get two values X and Y X and Y.

491
00:33:36,550 --> 00:33:39,510
X is integer so x is in it.

492
00:33:39,520 --> 00:33:41,580
So right now is a peer.

493
00:33:41,650 --> 00:33:43,840
So this is appeared again.

494
00:33:43,870 --> 00:33:48,340
I will have two parts x and y two the first is double.

495
00:33:48,490 --> 00:33:52,300
So here you have double and the second is character.

496
00:33:52,390 --> 00:33:54,040
So here you have Gary.

497
00:33:54,190 --> 00:33:56,620
So this is how everything is working.

498
00:33:56,680 --> 00:33:57,460
Now one more thing.

499
00:33:57,490 --> 00:34:02,000
So this is a nesting right so you can do many levels of nesting.

500
00:34:02,020 --> 00:34:02,290
Okay.

501
00:34:02,300 --> 00:34:05,880
So so you can do as many levels of nesting as you want.

502
00:34:05,890 --> 00:34:08,180
So this is one level of nesting right.

503
00:34:08,200 --> 00:34:10,660
So this is first level of nesting.

504
00:34:10,660 --> 00:34:16,560
So speaking from my own experience you will never acquire listing of second level or more.

505
00:34:17,920 --> 00:34:20,160
So the first level nesting is more than enough.

506
00:34:20,170 --> 00:34:22,050
So this is more than enough.

507
00:34:22,180 --> 00:34:23,490
This is more than enough.

508
00:34:23,500 --> 00:34:26,080
So first level of nesting is good enough.

509
00:34:26,290 --> 00:34:32,410
You will never encountered a problem in which you need to use second level of nesting or mode.

510
00:34:33,370 --> 00:34:36,140
So this is all in templates.

511
00:34:36,220 --> 00:34:39,040
So if you have any doubt in templates you can ask me.

512
00:34:39,070 --> 00:34:41,060
OK so this is it from this video.

513
00:34:41,230 --> 00:34:41,650
Thank you.
