Created
February 12, 2017 14:18
-
-
Save zeraf29/e227141cc702ac422e8f8640d6cbcfe1 to your computer and use it in GitHub Desktop.
python class example3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car(): | |
def exclaim(self): | |
print("I'm a Car!") | |
class Yugo(Car): #상속 받을 부모 클래스의 명칭을 ()에 기입 | |
def exclaim(self): | |
print("I'm a Yugo!") #method override | |
def need_a_push(self): | |
print("A little hlpe here?") #추가 선언 | |
aCar = Car() | |
bCar = Yugo() | |
bCar.need_a_push() #추가 선언한 method 호출 | |
#aCar.need_a_push() #자식 클래스에서 추가 선언한 method는 부모에 반영 안됨 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment