【问题标题】:When an object of a class has arguments, how do you pass it as an argument of a method in another class当一个类的对象有参数时,如何将它作为另一个类中方法的参数传递
【发布时间】:2022-01-25 17:45:26
【问题描述】:

这个新类(CashRegister)应该接受零售对象作为参数 我该怎么做 零售类也有 3 个论点

import retail
item = retail.RetailItem(desc, unit, price)

class CashRegister:

    def purchase_item(self):
        pass

    def get_total(self):
        pass

【问题讨论】:

    标签: python oop


    【解决方案1】:

    我不确定你是否指的是继承,如果是在这个链接中:https://www.w3schools.com/python/python_inheritance.asp你可以找到一些继承的例子,希望它有所帮助

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多