What's the difference between a method and a function?

前端 未结 30 3326
粉色の甜心
粉色の甜心 2020-11-21 05:08

Can someone provide a simple explanation of methods vs. functions in OOP context?

30条回答
  •  心在旅途
    2020-11-21 05:38

    A method is on an object.
    A function is independent of an object.

    For Java and C#, there are only methods.
    For C, there are only functions.

    For C++ and Python it would depend on whether or not you're in a class.

提交回复
热议问题