Using inheritance in python

后端 未结 4 1244
轮回少年
轮回少年 2021-01-03 06:36

this is my homework assignment, I saw it posted on the website before, but it looks like it was unsolved and I got a different error message than a person asking that questi

4条回答
  •  庸人自扰
    2021-01-03 07:13

    Look at the declaration of Executive.__init__:

    def __init__(self, name, wage, yearlyBonus):
    

    Nowhere in there does it declare a variable named salary. But when you call the superclass constructor,

        Employee.__init__(self, name, salary) 
    

    you are asking Python to pass the value of a variable named salary as the third parameter. Python is just complaining that this variable does not exist.

    I imagine you can figure out how to fix it from there. :-)

提交回复
热议问题