Skip to content

Instantly share code, notes, and snippets.

@zeraf29
Created February 12, 2017 14:18
Show Gist options
  • Save zeraf29/e227141cc702ac422e8f8640d6cbcfe1 to your computer and use it in GitHub Desktop.
Save zeraf29/e227141cc702ac422e8f8640d6cbcfe1 to your computer and use it in GitHub Desktop.
python class example3
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