Why is this happening is because one of our function, that brain function was virtual function.
So we were able to change the definition of the virtual function at that one time because it was virtual.
So once that is inherited by the right place, it was able to bring the right brain function.
OK?
It was able to use the right brain function.
But in this case, this is that function which was inherited and rupturing the show.
It was not a virtual function.
So even if we are putting that show off function from that right glass object, it was just printing
the other one.
OK?
The base class show function, because it was not all of them.
It was same.
The meaning of this show function last, not getting cancer, that only this was getting answered.
That is because that function was not declared us.
Let's hope you have understood this concept.
You will take some time to digest all this concept because it's a huge topic.
And if you need more information, you can always refer to the resources section, which I will give
in my website and you can for all those things to read as well so that you will understand more about
this things.
So if you have any kind of questions, please read the end of the course and I will be seeing these
to contact me.
So then you can put it like that.
Get in touch with me and you can clarify your questions.
OK, so that's all about the literature functions.
So you have understood the concept of what a functions and what your functions are a great way to achieve
runtime polymorphism runtime.
Bottom line for somebody that achieved or literally blind at or our friends of based type, also based
glass lined up can pointed objects of base class, as well as the object of the right class in their
vocal base class.
Bind up the PDA contain star press off Object B off the right class.
So we are creating a if you are a member of the court, which I was showing you without creating a pointer
off the base class for us and we were starting that press of the object of the RAM class there.
And according to our runtime polymorphism, you have used that word, Cherokee word, and that virtual
key word was actually showing that output for that derived class.
While the non-material function show was not showing that output for that bay like a drive class, it
was showing up for that base class.
So that's the difference between base class and derived class.
So now we move to the next topic abstract class.
It's also a simple topic, and abstract class is a class.
It's an automatic last week ltd in C++, but in order to make it class abstract, what we need to make
sure that we should have at least one curatorial function.
So then you will be thinking like, well, what will be that PR related function?
Right?
So the bureau will still function is a function that has no definition.
So we will be writing a function inside our base class, but we will be giving no definition to it.
What we will do, then we will inherit that function to it, the right class and we will be the definition
of the function, all of that.
So that will be the thing which will be happening.
So as soon you will be able to see that.
Let's go to the example of that.
So what are we just contain at least one PR little function as far abstract class?
OK, so let's go to the demo, then you will be getting that.
So I have this abstract program over here.
See, if you look out here, you can see our class size shape and that glass part rectangle and OneNote
class on triangle.
Here we have to compute the area of the shape.
OK.
Let it be triangle or let it be back then we want to remove the of the sheet.
But why do you need to do is like if you want to come like, compile daily, appreciate each shape has
its own formula.
So for computing the VAT allied values of each shape, it's having a formula like four rectangle.
It's length, the numerator in the high three and four triangle.
It's like waiting to hide by two for most of the ranks.
OK, I'll be.
It's half into base into how I got ripped into high by two, right?
So that's what we are doing actually our shape here.
If you notice we have a class called shape.
We have a function to set our.
And set the height.
OK, accepting width and height from like this argument said, then sit tight.
And then what will happen?
Dysfonctionnement said that between height parameters and what will happen next, we have a virtual
function called area and see that virtual function guard area is declared inside the glass shape, but
it is equal to zero.
OK, that means this virtual function is not given any definition right now.
So what we are doing is we are inheriting that shape two rectangle glass and are saying inheriting the
same shape shaped triangular glass.
And then we are redefining the area.
We are defining the area function s return built into height for rectangular and return half of the
height for diameter.
So our function, which which was having Midwest bar area in the shape plot last not having it.
Pure definition, OK?
It was garden.
It's just initialized to zero.
So this form of initialization or this form or function sort of like pure virtual function because it's
not having it definition if you are so yet, there is no function definition of it here.
And one more thing is like hourglass shape is part of an abstract class because it's containing at least
one with Japan in this area with jump function.
So our shape glasses containing this virtual function, so it's having one part of a larger function
inside that.
So our shape process quite abstract as it's very simple theoretical concept.
And now you can see on the program, we are creating two objects one for rectangle and one for triangles.
We are setting the bit of rectangle object in the fight and height of rectangle object.
And similarly, we are setting the width of triangle object to trendy and setting the height of triangles.
Object two eight.
And now we are printing it using that respective area functions.
That was the PR function.
Now let's see how this program will work.
So C++ Abstract Art CPB nine now dot slash is not.
See, we have the rectangular areas, 50, because it was doing this, then in the four feet and triangles
area, it was passing trendy and we saw a half of twenty eight, right?
It's a so trendy and radius 160.
I think that values 80.
So we have bought that two things, right?
And what happened, actually?
We were using the same function, which was inside the base glass, but with different formulas or definitions.
So that's all about the abstract glass and there and a smart pick up of our bottom of this up what we
have understood this topic so we can move to that next lecture.