kopia lustrzana https://github.com/animator/learn-python
Update classes.md
rodzic
406227a4ad
commit
937f62905b
|
@ -204,15 +204,8 @@ class Derived(Base):
|
|||
# Driver code
|
||||
obj1 = Base()
|
||||
print(obj1.a)
|
||||
|
||||
# Uncommenting print(obj1.c) will
|
||||
# raise an AttributeError
|
||||
|
||||
# Uncommenting obj2 = Derived() will
|
||||
# also raise an AttributeError as
|
||||
# private member of base class
|
||||
# is called inside derived class
|
||||
|
||||
# output
|
||||
It will raises error because private members cannot be used outside the class even not for derived classes
|
||||
|
||||
**Inheritence**
|
||||
->Inheritance allows us to define a class that inherits all the methods and properties from another class.
|
||||
|
@ -452,4 +445,4 @@ Ostriches cannot fly.
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue