Override


#1

Can anyone please explain Override Example? It’s confusing…please HELP…


#2

exercise url:

https://www.codecademy.com/courses/learn-python/lessons/introduction-to-classes/exercises/override?action=resume_content_item

We create two classes, Employee and CEO

of each class we create an instance (emp and ceo)

emp.greet(ceo) will call great method of Employee class:

  def greet(self, other):
    print "Hello, %s" % other.name

emp is greeting the ceo (ceo is pass as argument to other parameter of greet method)

ceo.greet(emp) calls great method of CEO class:

  def greet(self, other):
    print "Get back to work, %s!" % other.name

ceo is greeting the emp (emp is passed as argument to other parameter of great method)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.