Difference between Function and Method
Author -
Programmer Fect
March 25, 2020
Function
Function do not have any reference variables.
All data that is passed to a function is explicitly passed.
It does not have access controlling i.e. Function(other than static functions) declares and defines anywhere in the code.
Function applies to both object oriented and non-object oriented language(procedural language eg: C, Scripting language eg: Python, JavaScript etc)
Function have independent existance means they can be defined outside of the class.
Function are called independently.
Method
Method are called by reference variables.
It is implicitly passed the object for which it was called.
It has access controlling i.e. Method should declare and define in the class only.
Method is only applicable to object oriented programming language like C++, C#, Java etc.
Method do not have independent existance they are always defined with in class.
Method are called using instance or object.