- Hands-On Penetration Testing with Python
- Furqan Khan
- 154字
- 2021-07-02 14:14:00
Polymorphism with classes (abstract classes)
There may be occasions in which we would want to define a template of a class in terms of what that class must do, but not in terms of how it should do it – we would want to leave that to the implementation of the class. This is where we can make use of abstract classes. Let's create a script called Poly_class.py and add the following code:

It can be seen that we have an abstract class called Shape, which has an area method. The area method is not implemented in this class, but it would be implemented in the child class. The Square and Circle child classes override the area method. The area method is polymorphic, which means that if a square overrides it, it implements the area of a square and when a Circle class overrides it, it implements the area of a circle.
- Go Web編程
- Learning Unreal Engine Android Game Development
- 大學(xué)計(jì)算機(jī)基礎(chǔ)
- 代碼閱讀
- 零基礎(chǔ)學(xué)Python編程(少兒趣味版)
- Web Developer's Reference Guide
- 黑莓(BlackBerry)開發(fā)從入門到精通
- OpenCV 3.0 Computer Vision with Java
- INSTANT Premium Drupal Themes
- Scratch編程從入門到精通
- Getting Started with JUCE
- 你必須知道的.NET(第2版)
- Android熱門應(yīng)用開發(fā)詳解
- Learning iOS Penetration Testing
- 大話程序員:從入門到優(yōu)秀全攻略