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

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

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

30条回答
  •  醉话见心
    2020-11-21 05:43

    To a first order approximation, a method (in C++ style OO) is another word for a member function, that is a function that is part of a class.

    In languages like C/C++ you can have functions which are not members of a class; you don't call a function not associated with a class a method.

提交回复
热议问题