Functions and Methods

Based on this Stack Overflow response, we can define Functions and Methods as follows:

A Function is a piece of code this is called by name. It can be passed data to operate on (i.e. the parameters) and can optionally return data (the return value). All data that is passed to a function is explicitly passed.

A Method is a piece of code that is called by a name this is associated with an object. In most respects it is identical to a function except for two key differences:

1. A method is implicitly passed the object on which it was called.

2. A method is able to operate on data that is contained within the class (remembering that an object is an instance of a class – the class is the definition, the object is an instance of that data).

For the sake of our simplified programming concepts, we are going to keep them synonymous, but just keep in mind that is Java they’re called methods, C they’re called functions, and C++ they’re called members.