Single inheritence with constractor overriding
#! single inheritence with constractor overriding
"""Parent class a constractor ache kinthu child class a nai..tahole child
class ar objecr diye parent ar constratcor use amra korachi ....but ...
jodi child and parent both class a constractor thake tahole ki hobe??
tokhon parent er constractor child er jonno karjokori hobe na
child ar conostractor parent ar constractor ke replace kore deba
aita ka e bole constractor overriding """
class Father:
def __init__(self):
self.money="1 lakh"
self.jomi="5 katha"
print("father class constractor call holo")
def show(self):
print("Father class instance mathod")
class Child(Father):
def __init__(self):
self.money="3 koty"
self.car="BMW"
print("Son class constractor call holo")
def show1(self):
print("child class instance mathod")
##################################################################################
"""
munna=Child()
Print Output:
father class constractor call holo
aibar son class a constractor lagai
"""
#aibar son er constractor call hobe
munna=Child()
#money likhle kar money accsess korbe>
print(munna.money) #of course son er ta
#?son er jomi nai jomi likhle kar money accsess korbe>
#?print(munna.jomi) #JOMI ar access hobe na.karon constractor overriding hoise
#################################################################################
#akhon ami father ar object banale kaj hobe???
shohid=Father()
print(shohid.jomi)
print(shohid.money)
#aramse kaj hobe
Comments
Post a Comment