What is the difference between function and method ? Can any one say with suitable example say what are the differences? Where we say some routines are called function and where it is called method?
Asked
Active
Viewed 2,579 times
1 Answers
0
Function or a method is a named callable piece of code which performs some operations and optionally returns a value.
In c language the term function is used. Java & C# people call these methods (and a function in this case is defined within a class/object).
A C++ programmer might call it a function or sometimes method (depending on if they are writing procedural style c++ code or are doing object oriented way of c++).
You call a function by just calling it's name like result = mySum(num1, num2);
You would call a method by referencing its object first like
result = MyCalc.mySum(num1,num2);
Check the link in CubanAzucy's answer. It is already discussed in great detail on Stack Overflow.

Abdullah Leghari
- 2,332
- 3
- 24
- 40