Hello everyone so welcome to this new session.
So we've already discussed about object oriented programming but there are a few topics that are left.
OK.
So let's discuss them one by one.
OK.
So there are some concepts self hopes they are abstraction
and get solution
and that are dance and polymorphism polymorphism
OK.
So in this we do we will try to cover these two.
Okay.
So we will go at these two and this will do.
And then in the next two videos we will try to cover inheritance and polymorphism.
Okay so let's start with the ancap solution.
Okay so let's start with these encapsulation.
So what is the meaning of encapsulation
so the meaning of an absolution is clubbing.
We have two club things.
Okay.
So combining things.
So what we're doing encapsulation is we really combine the data and the functions data members and the
functions okay.
So combining that with the members and the functions of an entity is what we call encapsulation okay.
Combining leader the members and the functions of an entity is what we call ancap solution okay.
So we can achieve encapsulation with the help of a class.
Okay.
So this is nothing but a class.
So with the help of class we can achieve encapsulation.
Let us take an example.
So suppose I have a student class so industrial in the class let's say the duty members let's say the
properties are.
I have a name.
Name of the student age let's say I address okay and similarly
we have functions like certain number
and change and dress
okay.
So these are the data members and these are the functions okay.
So if you will combine the data members and the functions of an entity then it is called Encapsulation.
So here we are combining the data members and functions into a single unit.
Okay so this is a single unit
with the help of glass with the help of glass.
We can achieve our goal of encapsulation Okay so now we will color abstraction.
Okay.
So let's see what is abstraction.
So what is the meaning of abstraction so the meaning of abstraction is to hide hiding what we can see
hide.
Okay.
So what we will do we will hide the unnecessary details.
Okay.
Hiding the tools which are not important from the outside world.
Okay.
Hide the details which are not relevant to the outside world.
For example we have a TV.
Okay.
So for example let us talk about television.
So how we will operate television we will operate TV using the remote.
Okay.
So with the help of remote we can perform many operations such as on and off changing channels.
Increase volume or decrease volume.
Okay.
But we do not know what happens internally when you press a button.
Okay.
We do not know what happens and then we leave whenever we press a button.
Okay.
So there is no need for us to know that.
Okay.
It is not important for us to know what happens when we press a button.
So there is no need for us to know what happens internally and let's have one more example let's take
the example of a car.
Okay so we all know how to drive a car but we do not know how a car works.
Okay we do not need to know how a car works to drive a car.
Okay.
So we are hiding the properties we are hiding how a car works from the user Okay use it will simply
come and drive the car.
There is no need for us to know how a car works.
Okay.
So these are the real world example.
Now let's seen called So what we are doing good.
So we all know we have studied about smart yesterday about sorting.
So we have AI and built heart function.
So what does symbol chart function will do.
It will take it as input and it will sort the idea accordingly.
Okay.
So we have this inbuilt heart function we have this inbuilt heart function.
So internally how it works.
I don't care.
Okay.
So what we will do but use every Lou it will simply call the function sort.
And it will give daddy and that I will get started now use it doesn't care how internally this sort
function work although we yesterday studied about heart function but there is no need for us to like.
There is no need for us to study how a starting works.
We can likely use this function.
Okay so internally how it works I don't care.
Similarly we have something called SDL it stands for standard template library.
So what happens is we have many of your structures
so the example of the district just like stacks.
Q hash map and so on.
Okay so we have many data centers inside there still.
These data suggest I already implemented.
Okay so many of your district chairs are already implemented in standard amplitude in standard template
library.
So what we will do for example if I want to create a stack I will simply write create a stack often
Deja and the name of the stack is as OK if I want to push element inside the stack.
I will write as not push if I want to pop element.
I will write as dark pop Okay so I don't care how internally it works okay.
I don't care how I intend to lead the stack is implemented in the standard template library.
I will just use these lines and I will get a stack okay.
So we are hiding all these things from the use it.
So there it is called abstraction.
So how can we achieve abstraction so we can achieve abstraction using glass.
Okay so let's see how so let's say we have a student class inside the student class.
I have name rule number address so we have a class student and they say this within a class we have
three properties name number and address.
Now what I want to do is I want to hide the rule number from the outside world.
Okay I want to hide this property from the outside world.
So how we will do it in the class simply we will make this property a private property.
Okay.
So making the properties as private properties this is called abstraction.
Whenever we make a property private this will not be accessible to the outside world.
Okay.
So this thing.
So making the properties if you make properties private then we call it abstraction.
We are hiding the property.
Okay.
So we can achieve abstraction using the class.
If someone wants to access the raw lumber it has to call a public function of this class.
So we will create a public function of this class.
And if user wants to access the raw number you can access the rule number with the help of the public
functions.
Okay.
But this property is directly not visible to the outside world.
Okay.
So we are hiding this property.
So we have discussed what is abstraction and how we can achieve it.
Now the question is why we want to hide details okay why we want to do abstractions.
So there are two main reasons for doing abstractions.
And the first reason is so the first major reason is ablation or changes so what happens is if we change
our own code then and use the code should not be affected.
Okay.
So if we change our own code then user code should not be affected.
So suppose I have a start function the art function will take as input and it will sort the area.
Okay so let's assume initially art function internally uses bubbles art Okay let's assume we know this
is not right but let us assume initially this thought function uses bubbles art.
So how will user call this function.
It will write a user will call the function in this minute sort.
And it will give the idea.
So now after some time we realize that bubbles art is not an efficient sorting out your name it is and
square.
So with changes we change internally how does art how this art function work which changes the bubbles
out in two quick art.
Earlier we used to use bubbles art but now we are using quick art.
Inside this art function internally.
Okay so if I am using quick sword now so we'll use a code will be affected.
So the output is no.
So the answer is no use the code will not break.
Okay.
If user has allowed some program inside the program if you use it is using this art function and if
I change the internal workings of this art function then user call will not be affected.
User code will not big.
Okay so this is the first reason why we do abstraction.
Okay.
So if we change our own code then use a code should not be affected.
Now the second main reason is to avoid errors second major reason for doing a restriction is to avoid
errors.
So how can we avoid this using extinction.
So suppose this art function is a public function.
So if this is a public function what will happen.
Anyone can come and change it.
Okay.
And your numbers can come and it can change the internal properties of this art function internal logic
of this art function.
Okay.
So what will happen.
User can introduce errors in our code.
Okay.
But you don't want those errors.
So what do we do we will make this art function private okay.
So what we will do we will hide the crucial properties since we will hide the crucial properties.
User cannot come and change those properties so user cannot introduce those errors in our code.
Okay so we should always do.
Abstraction Okay so this is all about abstraction.
And next to we a deal we will discuss about inheritance.
Okay thank you.