0
What is the difference between function and method?
3 Answers
+ 12
A method is a function that is declared within a class, to use a method one would need a reference to either a class or an object, depending on whether the method was declared as a class' method, or as an instance method. A regular function is declared independently, it does not belong to a class, therefore, it can be used/called without the need of a class/object.
Hth, cmiiw
+ 9
difference between a Functionand a Method:Â
Functionsare defined outside of classes, while Methodsare defined inside of and part of classes. In OO languages such as Object Pascal or C++, a "method" is a function associated with an object.
+ 2
just context, a method is a class function