상세 컨텐츠

본문 제목

파이썬 상속 개념

파이썬

by somiyuralove 2023. 4. 14. 20:02

본문

Python Inheritance

Inheritance allows us to define a class that inherits all the methods and properties from another class.

Parent class is the class being inherited from, also called base class.

Child class is the class that inherits from another class, also called derived class.

Create a Parent Class
Any class can be a parent class, so the syntax is the same as creating any other class:

Create a Child Class
To create a class that inherits the functionality from another class, send the parent class as a parameter when creating the child class:

Now the Dog class has the same properties and methods as the Animal class.

Use the Dog class to create an object, and then execute the prtNameAndTalk method:

* Reference and super thanks : w3schools.com


'파이썬' 카테고리의 다른 글

파이썬 클래스 개념  (0) 2023.04.17
파이썬 detetime 모듈 개념  (0) 2023.04.16
파이썬 모듈의 개념  (0) 2023.04.14
format  (0) 2023.04.12

관련글 더보기

댓글 영역