Inheritance such as Python

Source: Internet
Author: User

In inheritance we call the parent class: parent class, Base class, Super class

Refer to Subclass: subclass, derived class, inheriting class

The child class and the parent class are the relationships of is.

If: P1 is an instance of the parent class, we can say that P1 is a parent class, but it cannot be said to be a subclass.

P2 is an example of a subclass, and we can say that P2 is a subclass, or P2 is a parent class.

class person (object):     def __init__ (self,name,gnder):         = name        = gender        class  Student (person):    def_ _init__(self,name,gender,school,score):        Super (student,self). __init__ (name,gender)         = School        = Score

This is the student from the person parent class, It is important to note that

Super (student,self). __init__ (name,gender) is a statement used to initialize the parent class

Inheritance such as Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.