正在加载图片...
Invoking Methods We can call class methods in two ways:as a bound method and as a function. Invoking class methods as a bound method: Bound methods are accessed through the instance and implicitly pass the instance object in as the first argument of the method. <instance>.<method_ a gets passed in to the deposit function as the first argument a.depesit(5) Invoking class methods as functions: We can use the class name to directly call a method.These follow our typical function call rules and nothing is implicitly passed in. <class_name>.<method_name>(<instance>,<arguments>) Account.deposit(a,5) deposit takes in two argumentsInvoking Methods We can call class methods in two ways: as a bound method and as a function. Invoking class methods as a bound method: - Bound methods are accessed through the instance and implicitly pass the instance object in as the first argument of the method. - <instance>.<method_name>(<arguments>) - a.deposit(5) a gets passed in to the deposit function as the first argument Invoking class methods as functions: - We can use the class name to directly call a method. These follow our typical function call rules and nothing is implicitly passed in. - <class_name>.<method_name>(<instance>, <arguments>) - Account.deposit(a, 5) deposit takes in two arguments
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有