Hello, and welcome to the 64th tutorial in the c++ program series. And in this part we'll be looking at the abstract base class. And abstract base class is a class that can't be instantiated and is used for deriving classes only basically what that mean you can't create a object of that class. And you declare all methods that pure virtual which can be done by emitting the method body but assigning the value zero to it. This is really simple, but it's something really powerful. And as loyal to the programming tutorial from now on, we'll be introducing advanced topics.
This is also an advanced topic. So what we want to do is create a class called shape made public. So what we're going to do is create a virtual method and to do that it is really simple. Virtual uncovered virtual methods Although we don't get a pure virtual method, basically what you do is you assign it the value zero. And this prevents this class from being instantiated with try instantiate it in a moment. So you can see the sort of error that you'll get from the compiler.
Point. And then we're going to create another class. It's going to inherit from the shape class. Public shape. And then what we're gonna do it public. We're gonna do an inline method is to quickly get done with boy height.
As you can see, it's got the width and height from this here. What we're going to do now is create some objects. So shape derived st st dot width equals nine to st dot point because eight USD dot area we should get 720 we're gonna do is run this so get a value of 720 bug free changes to shape and form runner. It's a build file variable type shape is an abstract class basically copy instantiated data for abstract classes. In the next part of this series, we'll be looking at error handling. You have any question?
Feel free to message us at support at solar systems calm Okay, email will be in the description you can comment on this video or just sterically message before you do, all the calling for source code will also be in the description. And as usual, thanks for watching and I hope you have a nice day.