1
00:00:00,180 --> 00:00:01,950
All applauding in C++.

2
00:00:02,160 --> 00:00:07,740
So, you know, like C++ is very famous for its polymorphism, right?

3
00:00:07,800 --> 00:00:14,880
So polymorphism is an important feature of C++, and it means like processing the same thing in a different

4
00:00:14,880 --> 00:00:20,820
way and overloading is a good example for polymorphism in C++ anyway.

5
00:00:21,150 --> 00:00:24,030
Let small and deep dive into overload.

6
00:00:24,210 --> 00:00:27,150
So there are two types of all learning primarily.

7
00:00:27,240 --> 00:00:30,240
One is, you know, learning and other one is all great.

8
00:00:30,450 --> 00:00:30,960
All right.

9
00:00:31,110 --> 00:00:34,140
So let's discuss function overloading at first.

10
00:00:34,300 --> 00:00:36,840
Suppose if we want to create a function?

11
00:00:36,870 --> 00:00:39,900
OK and same function.

12
00:00:39,900 --> 00:00:42,120
We have different properties.

13
00:00:42,300 --> 00:00:48,390
So sometimes we can add two numbers by using a function called out in another situation.

14
00:00:48,600 --> 00:00:56,160
You can add two strings, or you can add two strings and create that new string.

15
00:00:56,610 --> 00:01:02,540
But the function name can be add right because it's doing that issue, but it's not adding up numbers.

16
00:01:02,610 --> 00:01:11,310
So supposing I want to do multiple actions with the same function name, that's very much possible in

17
00:01:11,310 --> 00:01:14,690
C++, so that scope function all along.

18
00:01:14,760 --> 00:01:20,700
So it will be having same function name, but it will having multiple definitions.

19
00:01:20,730 --> 00:01:28,590
And one thing you have to remember that while you are creating it, all audit functions is the definition

20
00:01:28,590 --> 00:01:30,990
of the function must be different from each other.

21
00:01:30,990 --> 00:01:35,130
And also the type and number of arguments should also differ.

22
00:01:35,260 --> 00:01:41,130
Generally, you can create create multiple functions with the same name, but for different purposes.

23
00:01:41,370 --> 00:01:42,150
So what happens?

24
00:01:42,150 --> 00:01:49,920
C++ will use that idea of return types and argument types to understand which function is being called.

25
00:01:49,950 --> 00:01:55,290
You will not having a clear idea right now, but when you see the program, it will be clear for you.

26
00:01:55,290 --> 00:02:01,320
I am guaranteeing that OK, return times should be different, but that kind of functions cannot be

27
00:02:01,320 --> 00:02:06,480
all ordered if there are like a vital function as a returning integer value and that are turning it

28
00:02:06,720 --> 00:02:07,620
string value.

29
00:02:07,890 --> 00:02:10,770
Based on that, you will not be able to outlaw that function.

30
00:02:10,980 --> 00:02:11,370
OK.

31
00:02:11,550 --> 00:02:17,250
Why does our learning function, same function name, but different function definitions?

32
00:02:17,400 --> 00:02:21,420
So we will be creating a function like that, not creating one function.

33
00:02:21,450 --> 00:02:22,800
Many functions like that.

34
00:02:22,890 --> 00:02:24,930
So let's move to that demo.

35
00:02:25,020 --> 00:02:30,090
So here you have the example here I have a function card, not a function.

36
00:02:30,390 --> 00:02:35,670
A class card, print data and having three different function inside that class.

37
00:02:35,790 --> 00:02:37,890
See the names of the function function.

38
00:02:37,900 --> 00:02:42,270
One is also called print media used to print integer value.

39
00:02:42,390 --> 00:02:47,490
The second function is also called print, but it is used to print it floating point value.

40
00:02:47,490 --> 00:02:49,350
That function is also part print.

41
00:02:49,470 --> 00:02:51,780
It is used to print that character value.

42
00:02:51,810 --> 00:02:54,930
So how you can differentiate which function should be card.

43
00:02:54,930 --> 00:02:59,470
If I am willing to print a integer value, which function should be condemning this?

44
00:02:59,490 --> 00:03:00,810
The first one should be called right.

45
00:03:01,050 --> 00:03:04,840
If I'm printing the planning to print a character value, which should be going.

46
00:03:04,890 --> 00:03:08,220
The third function will be called how we can differentiate that.

47
00:03:08,460 --> 00:03:12,580
So for that, we can use that type of arguments on the function.

48
00:03:12,600 --> 00:03:14,460
These are the function arguments here.

49
00:03:14,460 --> 00:03:17,820
The function argument is int he had a function out of them and is double.

50
00:03:18,030 --> 00:03:19,800
And here the function out of the sky.

51
00:03:19,980 --> 00:03:25,260
So here we can use the type and even you can use the numberof arguments here, all the functions.

52
00:03:25,260 --> 00:03:27,240
In this case as having only one argument.

53
00:03:27,450 --> 00:03:33,840
But if some function of print is having two arguments and we are calling the function with two arguments,

54
00:03:34,230 --> 00:03:35,820
that is that will be called.

55
00:03:35,970 --> 00:03:40,780
So you can see there are two overloads because our compiler is very intelligent.

56
00:03:40,800 --> 00:03:42,660
Our IRA is very intelligent.

57
00:03:42,690 --> 00:03:48,990
It is also showing that how we should pseudo code can itself recognize that like to have same function

58
00:03:48,990 --> 00:03:49,320
name.

59
00:03:49,320 --> 00:03:50,820
Two other function also exists.

60
00:03:50,880 --> 00:03:53,880
Now let's execute this program and see it in action.

61
00:03:54,090 --> 00:03:59,970
So D-plus plus function of our Lord Dart CBB.

62
00:04:00,090 --> 00:04:01,860
Sorry, I'm not in desktop.

63
00:04:02,400 --> 00:04:06,600
Let me move the desktop first, then let me execute this command.

64
00:04:07,320 --> 00:04:11,790
OK, this is some A. So we can use string on here and start off.

65
00:04:11,800 --> 00:04:13,170
Yeah, I'm using string.

66
00:04:15,940 --> 00:04:22,770
Off key now I am trying to save this program, and yes, it's gone by now, let's see.

67
00:04:22,780 --> 00:04:26,280
I have created an object called BD BD Dot Brinda five.

68
00:04:26,500 --> 00:04:36,340
OK, let's put a note out dog-eared or C fast function, but in the end it is executed, printing the

69
00:04:36,520 --> 00:04:40,840
integer value because I have passed that fire, which is an integer value.

70
00:04:40,990 --> 00:04:42,460
So what will happen in the back?

71
00:04:42,670 --> 00:04:46,850
That number five will be matched over to this.

72
00:04:46,870 --> 00:04:53,050
This one is match, so it will be executed so that the main display, right, which brain function is

73
00:04:53,050 --> 00:04:56,350
having the right match will be the brain function will be executed.

74
00:04:56,500 --> 00:05:01,180
Suppose if I have two arguments, then also you can do the same.

75
00:05:01,250 --> 00:05:02,410
You can alter the function.

76
00:05:02,410 --> 00:05:07,180
So similarly, we have the flawed and character being printed out here.

77
00:05:07,420 --> 00:05:14,210
So based on the type of this data, this compiler found the right one write function and printed that

78
00:05:14,360 --> 00:05:15,600
that's the only thing.

79
00:05:15,880 --> 00:05:20,500
Now suppose if I have two arguments OK, why print?

80
00:05:20,530 --> 00:05:29,110
Same function name and while lauding indicate the two arguments int he x comma int white.

81
00:05:29,320 --> 00:05:31,180
So I have two arguments altogether.

82
00:05:32,350 --> 00:05:43,450
So now the brain function I'm giving out to argument function, then I am printing X and then let's

83
00:05:43,450 --> 00:05:47,440
use two x and is used to that.

84
00:05:47,440 --> 00:05:48,370
We have space.

85
00:05:48,620 --> 00:05:56,770
OK, go to the next line then printing that right now I am creating the same object, but I am calling

86
00:05:56,770 --> 00:05:57,940
that next print function.

87
00:05:57,980 --> 00:05:58,360
Print.

88
00:05:58,420 --> 00:06:01,000
I, Andy and I am passing to values.

89
00:06:01,240 --> 00:06:02,860
OK, what should be the values?

90
00:06:03,230 --> 00:06:05,320
90 and under?

91
00:06:05,890 --> 00:06:12,460
OK, now let's save this program, compile it again and see it in action and on out.

92
00:06:12,730 --> 00:06:15,880
See two out of the main function it pick the right one, right?

93
00:06:16,150 --> 00:06:19,660
This soldier had the same name print by this.

94
00:06:19,660 --> 00:06:22,410
I have passed two arguments, so this was picked.

95
00:06:22,660 --> 00:06:29,180
So only the best match will be picked based on the number of arguments and that type of arguments.

96
00:06:29,320 --> 00:06:29,710
OK.

97
00:06:29,950 --> 00:06:36,760
You have to note that is typically based on best match number and type of arguments and no one order.

98
00:06:36,770 --> 00:06:41,830
The function, which means the function with the same name and different definition will be Bob.

99
00:06:41,830 --> 00:06:43,930
You have understood this topic.

100
00:06:44,180 --> 00:06:49,570
Now let's go to our next topic is operator all along.

101
00:06:49,750 --> 00:06:57,940
So we have a lot of operators in C++, which we have already seen plus minus right or less, OK.

102
00:06:58,480 --> 00:07:07,060
But the main important security of C++, it's weakened if we have an existing operator, but we can

103
00:07:07,060 --> 00:07:10,000
still give the operator a new meaning.

104
00:07:10,240 --> 00:07:14,830
So we may be able to give the new meanings to existing operator in C++.

105
00:07:15,310 --> 00:07:17,320
So let me show you something.

106
00:07:17,470 --> 00:07:21,830
Suppose if I had operator call plus it can be.

107
00:07:21,830 --> 00:07:26,790
I used to add two numbers three five three plus five A.B.

108
00:07:26,830 --> 00:07:33,040
That is one way of using this operator plus, but I have one more way of using this.

109
00:07:33,040 --> 00:07:35,530
Plus, I can just change the meaning of this.

110
00:07:35,530 --> 00:07:39,160
Plus, suppose if I have two things, one is hello.

111
00:07:39,850 --> 00:07:44,920
Is a and I want to add this those things and create a new string guard.

112
00:07:45,610 --> 00:07:50,320
Hello, then this meaning can be also done by plus operator.

113
00:07:50,530 --> 00:07:57,670
So we walk in the existing meaning of an operator and to create a new meaning to that operator.

114
00:07:58,060 --> 00:08:00,790
That concept discard operator all along.

115
00:08:00,870 --> 00:08:07,390
And this can be done in both binary operator and NATO operator by another operator means the operator,

116
00:08:07,390 --> 00:08:09,560
which takes two arguments.

117
00:08:09,580 --> 00:08:15,730
This is a binary operator, plus is a binary operator because 3+ by Ecobee three is run out men and

118
00:08:15,730 --> 00:08:21,030
five is another, so it will be operating on two options that will be binary operator.

119
00:08:21,290 --> 00:08:27,280
Some operators at United NATO operator have operating on a single operation.

120
00:08:27,340 --> 00:08:31,810
OK, so that ex-members for NATO operators are increment and decrement operator.

121
00:08:31,960 --> 00:08:37,370
So we use A-plus Plus right eye plus plus, which means IEEE is the only option.

122
00:08:37,600 --> 00:08:42,790
You would just need to increment the value if I, if not adding if I was white, A-plus Plus will increment

123
00:08:42,790 --> 00:08:43,840
the value 5.6.

124
00:08:44,020 --> 00:08:45,640
But that is not doable.

125
00:08:45,640 --> 00:08:52,540
Potentially I use them right then united minus is that a minus minus then logical operators that these

126
00:08:52,540 --> 00:08:54,880
are like you're an area operator?

127
00:08:55,060 --> 00:09:03,370
So let's see how using C++, we can change the meaning of an operator and we can all warlord that embodies

128
00:09:03,370 --> 00:09:05,620
what binary and urinary operator OK.

129
00:09:05,920 --> 00:09:07,690
Yet I have explained that again.

130
00:09:08,020 --> 00:09:13,710
Binary Operator takes two arguments and following other examples of binary operators like Plus, we

131
00:09:13,720 --> 00:09:15,190
just want an addition minus.

132
00:09:15,310 --> 00:09:17,760
Or subtraction or division?

133
00:09:18,280 --> 00:09:22,870
So how you can all lower the binary operator here is the syntax.

134
00:09:23,320 --> 00:09:28,350
So class class name, then public, then return type operator.

135
00:09:28,360 --> 00:09:35,500
Here you will give the operator keyword, then you will give the symbol symbol will be plus, then you

136
00:09:35,500 --> 00:09:44,770
will give the number of arguments late in the call may be or string almost solely based on the meaning

137
00:09:44,770 --> 00:09:47,090
you want to give to our new operator.

138
00:09:47,150 --> 00:09:50,050
OK, let's go to the demo to understand this.

139
00:09:50,200 --> 00:09:53,560
I have given you an explanation for the syntax already.

140
00:09:53,770 --> 00:09:56,710
Okay, let's go to binary operator.

141
00:09:56,990 --> 00:10:00,460
Well, I want to clear my screen here.

142
00:10:00,670 --> 00:10:08,410
So here you have complex, which is a class, and it's having two parts real and imaginary.

143
00:10:08,440 --> 00:10:13,120
So what we are trying to do is we are going to add two complex numbers.

144
00:10:13,600 --> 00:10:16,510
So to add to complex numbers, we will be adding a.

145
00:10:16,990 --> 00:10:19,420
We will be having a real part, an imaginative fact.

146
00:10:19,660 --> 00:10:25,420
And if you know mathematics, how you can add to complex numbers, you can you should add the real parts

147
00:10:25,420 --> 00:10:29,880
together, then you should add the imaginary parts together that will be jettisoned.

148
00:10:30,100 --> 00:10:35,500
So input function may be calling the real part an imaginary part of a complex number.

149
00:10:35,680 --> 00:10:43,030
OK, then second complex number here again, go to this one vast complex number that input second complex

150
00:10:43,030 --> 00:10:49,870
number that we have created do complex numbers and while complex object for sorting that the side of

151
00:10:49,870 --> 00:10:50,460
the edition.

152
00:10:50,500 --> 00:10:56,010
So to suddenly go to the complex, one less complex to here this object, this complex one, this object

153
00:10:56,020 --> 00:10:56,830
is complex too.

154
00:10:56,920 --> 00:11:01,540
I will be giving the inputs real and imagined and if I could on, but it's more like, let's do it,

155
00:11:01,630 --> 00:11:02,800
then I am adding this.

156
00:11:02,800 --> 00:11:08,530
Plus our progress used not to function as you start again, but just amplifying this object and putting

157
00:11:08,530 --> 00:11:09,820
a plus sign on that mini.

158
00:11:10,060 --> 00:11:16,110
That means, like not our default plus operator, it should be downloaded less, which should be gone.

159
00:11:16,270 --> 00:11:19,180
Now let's go to the definition of our place operator.

160
00:11:19,390 --> 00:11:21,850
So this index I have already explained, right?

161
00:11:22,180 --> 00:11:23,560
And this is the argument.

162
00:11:23,560 --> 00:11:30,160
It will accept an object as an argument, then creating a temporary able to hold that at the same time,

163
00:11:30,160 --> 00:11:36,340
Dorian is equal to the plus object or create the L will be the value of that vast object.

164
00:11:36,430 --> 00:11:39,460
Then object or real will be the value of the second object.

165
00:11:39,650 --> 00:11:40,030
OK.

166
00:11:40,210 --> 00:11:47,020
Upon getting the first objects, the yield back then getting that second object to the first object

167
00:11:47,020 --> 00:11:51,970
does not need not to put this object on or something.

168
00:11:52,120 --> 00:11:54,790
You just need to put that variable name directly.

169
00:11:54,790 --> 00:11:58,240
That's how you all unload that operator in that space.

170
00:11:58,540 --> 00:12:06,820
So a plus object oriented then second fast object imaginary by plus second objects imaginary by then

171
00:12:06,820 --> 00:12:10,300
you are returning the time and will be coming out to the south.

172
00:12:10,540 --> 00:12:17,660
So the dock output, so output function will be showing that output complex number will part and imaginary

173
00:12:17,680 --> 00:12:18,040
part.

174
00:12:18,070 --> 00:12:19,390
OK, that's that only really.

175
00:12:19,810 --> 00:12:26,260
So let's see this in action compilers C++ binary or dark CVP.

176
00:12:26,530 --> 00:12:27,550
I think this is not.

177
00:12:27,670 --> 00:12:28,110
Yes.

178
00:12:28,630 --> 00:12:29,230
Oh, OK.

179
00:12:29,290 --> 00:12:31,240
A lot of errors that wiping out.

180
00:12:31,840 --> 00:12:35,440
So whenever there is a lot of errors, you need to debug that.

181
00:12:35,740 --> 00:12:41,560
So something is wrong or to get complex on, on and off grade.

182
00:12:41,770 --> 00:12:43,420
I thought this was going to be smooth.
