From the course: Transition from C# to Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Abstract classes

Abstract classes

From the course: Transition from C# to Python

Start my 1-month free trial

Abstract classes

- [Instructor] All right, we're going to get a little more advanced now and take a look at abstract classes. And abstract classes of course are great for providing base classes that are designed to be inherited from, but cannot be instantiated themselves. So let's take a look at our C# example, and that's in the abstract folder inside AbstractCS, and we'll open the program file, and if we scroll down, in the C# code for this example, I have an abstract base class named GraphicShape that defines an abstract function named CalcArea. And there are two base classes. There's circle and there's square. And they both inherit from graphic shape. And because the CalcArea function is abstract and provides no default implementation, every subclass of graphic shape has to provide an implementation of this method. So for example, the circle calculates its area by using the pi times r squared formula, where the square calculates its…

Contents