“comment utiliser le super” Réponses codées

comment utiliser le super

class Animal(object):
  def __init__(self, animal_type):
    print('Animal Type:', animal_type)
    
class Mammal(Animal):
  def __init__(self):

    # call superclass
    super().__init__('Mammal')
    print('Mammals give birth directly')
    
dog = Mammal()

# Output: Animal Type: Mammal
#         Mammals give birth directly
Boody Mohamed

comment utiliser le super

class Animal(object):
  def __init__(self, animal_type):
    print('Animal Type:', animal_type)
    
class Mammal(Animal):
  def __init__(self):

    # call superclass
    super().__init__('Mammal')
    print('Mammals give birth directly')
    
dog = Mammal()

# Output: Animal Type: Mammal
#         Mammals give birth directly
Boody Mohamed

comment utiliser le super

class Animal(object):
  def __init__(self, animal_type):
    print('Animal Type:', animal_type)
    
class Mammal(Animal):
  def __init__(self):

    # call superclass
    super().__init__('Mammal')
    #or you can use
    super().__init__()
    print('Mammals give birth directly')
    
dog = Mammal()

# Output: Animal Type: Mammal
#         Mammals give birth directly
Boody Mohamed

Réponses similaires à “comment utiliser le super”

Questions similaires à “comment utiliser le super”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code