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

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

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

30条回答
  •  自闭症患者
    2020-11-21 05:46

    Function - A function in an independent piece of code which includes some logic and must be called independently and are defined outside of class.

    Method - A method is an independent piece of code which is called in reference to some object and are be defined inside the class.

提交回复
热议问题