All applauding in C++.
So, you know, like C++ is very famous for its polymorphism, right?
So polymorphism is an important feature of C++, and it means like processing the same thing in a different
way and overloading is a good example for polymorphism in C++ anyway.
Let small and deep dive into overload.
So there are two types of all learning primarily.
One is, you know, learning and other one is all great.
All right.
So let's discuss function overloading at first.
Suppose if we want to create a function?
OK and same function.
We have different properties.
So sometimes we can add two numbers by using a function called out in another situation.
You can add two strings, or you can add two strings and create that new string.
But the function name can be add right because it's doing that issue, but it's not adding up numbers.
So supposing I want to do multiple actions with the same function name, that's very much possible in
C++, so that scope function all along.
So it will be having same function name, but it will having multiple definitions.
And one thing you have to remember that while you are creating it, all audit functions is the definition
of the function must be different from each other.
And also the type and number of arguments should also differ.
Generally, you can create create multiple functions with the same name, but for different purposes.
So what happens?
C++ will use that idea of return types and argument types to understand which function is being called.
You will not having a clear idea right now, but when you see the program, it will be clear for you.
I am guaranteeing that OK, return times should be different, but that kind of functions cannot be
all ordered if there are like a vital function as a returning integer value and that are turning it
string value.
Based on that, you will not be able to outlaw that function.
OK.
Why does our learning function, same function name, but different function definitions?
So we will be creating a function like that, not creating one function.
Many functions like that.
So let's move to that demo.
So here you have the example here I have a function card, not a function.
A class card, print data and having three different function inside that class.
See the names of the function function.
One is also called print media used to print integer value.
The second function is also called print, but it is used to print it floating point value.
That function is also part print.
It is used to print that character value.
So how you can differentiate which function should be card.
If I am willing to print a integer value, which function should be condemning this?
The first one should be called right.
If I'm printing the planning to print a character value, which should be going.
The third function will be called how we can differentiate that.
So for that, we can use that type of arguments on the function.
These are the function arguments here.
The function argument is int he had a function out of them and is double.
And here the function out of the sky.
So here we can use the type and even you can use the numberof arguments here, all the functions.
In this case as having only one argument.
But if some function of print is having two arguments and we are calling the function with two arguments,
that is that will be called.
So you can see there are two overloads because our compiler is very intelligent.
Our IRA is very intelligent.
It is also showing that how we should pseudo code can itself recognize that like to have same function
name.
Two other function also exists.
Now let's execute this program and see it in action.
So D-plus plus function of our Lord Dart CBB.
Sorry, I'm not in desktop.
Let me move the desktop first, then let me execute this command.
OK, this is some A. So we can use string on here and start off.
Yeah, I'm using string.
Off key now I am trying to save this program, and yes, it's gone by now, let's see.
I have created an object called BD BD Dot Brinda five.
OK, let's put a note out dog-eared or C fast function, but in the end it is executed, printing the
integer value because I have passed that fire, which is an integer value.
So what will happen in the back?
That number five will be matched over to this.
This one is match, so it will be executed so that the main display, right, which brain function is
having the right match will be the brain function will be executed.
Suppose if I have two arguments, then also you can do the same.
You can alter the function.
So similarly, we have the flawed and character being printed out here.
So based on the type of this data, this compiler found the right one write function and printed that
that's the only thing.
Now suppose if I have two arguments OK, why print?
Same function name and while lauding indicate the two arguments int he x comma int white.
So I have two arguments altogether.
So now the brain function I'm giving out to argument function, then I am printing X and then let's
use two x and is used to that.
We have space.
OK, go to the next line then printing that right now I am creating the same object, but I am calling
that next print function.
Print.
I, Andy and I am passing to values.
OK, what should be the values?
90 and under?
OK, now let's save this program, compile it again and see it in action and on out.
See two out of the main function it pick the right one, right?
This soldier had the same name print by this.
I have passed two arguments, so this was picked.
So only the best match will be picked based on the number of arguments and that type of arguments.
OK.
You have to note that is typically based on best match number and type of arguments and no one order.
The function, which means the function with the same name and different definition will be Bob.
You have understood this topic.
Now let's go to our next topic is operator all along.
So we have a lot of operators in C++, which we have already seen plus minus right or less, OK.
But the main important security of C++, it's weakened if we have an existing operator, but we can
still give the operator a new meaning.
So we may be able to give the new meanings to existing operator in C++.
So let me show you something.
Suppose if I had operator call plus it can be.
I used to add two numbers three five three plus five A.B.
That is one way of using this operator plus, but I have one more way of using this.
Plus, I can just change the meaning of this.
Plus, suppose if I have two things, one is hello.
Is a and I want to add this those things and create a new string guard.
Hello, then this meaning can be also done by plus operator.
So we walk in the existing meaning of an operator and to create a new meaning to that operator.
That concept discard operator all along.
And this can be done in both binary operator and NATO operator by another operator means the operator,
which takes two arguments.
This is a binary operator, plus is a binary operator because 3+ by Ecobee three is run out men and
five is another, so it will be operating on two options that will be binary operator.
Some operators at United NATO operator have operating on a single operation.
OK, so that ex-members for NATO operators are increment and decrement operator.
So we use A-plus Plus right eye plus plus, which means IEEE is the only option.
You would just need to increment the value if I, if not adding if I was white, A-plus Plus will increment
the value 5.6.
But that is not doable.
Potentially I use them right then united minus is that a minus minus then logical operators that these
are like you're an area operator?
So let's see how using C++, we can change the meaning of an operator and we can all warlord that embodies
what binary and urinary operator OK.
Yet I have explained that again.
Binary Operator takes two arguments and following other examples of binary operators like Plus, we
just want an addition minus.
Or subtraction or division?
So how you can all lower the binary operator here is the syntax.
So class class name, then public, then return type operator.
Here you will give the operator keyword, then you will give the symbol symbol will be plus, then you
will give the number of arguments late in the call may be or string almost solely based on the meaning
you want to give to our new operator.
OK, let's go to the demo to understand this.
I have given you an explanation for the syntax already.
Okay, let's go to binary operator.
Well, I want to clear my screen here.
So here you have complex, which is a class, and it's having two parts real and imaginary.
So what we are trying to do is we are going to add two complex numbers.
So to add to complex numbers, we will be adding a.
We will be having a real part, an imaginative fact.
And if you know mathematics, how you can add to complex numbers, you can you should add the real parts
together, then you should add the imaginary parts together that will be jettisoned.
So input function may be calling the real part an imaginary part of a complex number.
OK, then second complex number here again, go to this one vast complex number that input second complex
number that we have created do complex numbers and while complex object for sorting that the side of
the edition.
So to suddenly go to the complex, one less complex to here this object, this complex one, this object
is complex too.
I will be giving the inputs real and imagined and if I could on, but it's more like, let's do it,
then I am adding this.
Plus our progress used not to function as you start again, but just amplifying this object and putting
a plus sign on that mini.
That means, like not our default plus operator, it should be downloaded less, which should be gone.
Now let's go to the definition of our place operator.
So this index I have already explained, right?
And this is the argument.
It will accept an object as an argument, then creating a temporary able to hold that at the same time,
Dorian is equal to the plus object or create the L will be the value of that vast object.
Then object or real will be the value of the second object.
OK.
Upon getting the first objects, the yield back then getting that second object to the first object
does not need not to put this object on or something.
You just need to put that variable name directly.
That's how you all unload that operator in that space.
So a plus object oriented then second fast object imaginary by plus second objects imaginary by then
you are returning the time and will be coming out to the south.
So the dock output, so output function will be showing that output complex number will part and imaginary
part.
OK, that's that only really.
So let's see this in action compilers C++ binary or dark CVP.
I think this is not.
Yes.
Oh, OK.
A lot of errors that wiping out.
So whenever there is a lot of errors, you need to debug that.
So something is wrong or to get complex on, on and off grade.
I thought this was going to be smooth.