0

What is the difference between function and method?

13th Feb 2018, 7:05 AM
Namrata Bagh
Namrata Bagh - avatar
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
13th Feb 2018, 7:43 AM
Ipang
+ 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.
13th Feb 2018, 9:37 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
+ 2
just context, a method is a class function
13th Feb 2018, 8:37 AM
---
--- - avatar