I mostly agree on the first part, but on the second, I see it a quite bit differently.
From my perspective, I see a method as an operation that performs a task and returns no value, aside from indicating success or failure. I've always seen a function, in the context of an object, as an operation that may perform a task, but also definitely returns a value other than success or failure. I suppose that view of things may come from mathematics, where a function is defined as a mathematical operation that produces an output value, given a set of inputs. in mathematics, that output is always deteministic, but a function in a program need not be.
consider the following c++ class:
in my example, I would call dog::bark() a method, but I would call dog::getAge() a function.Code:class dog { public: void bark(); int getAge(); };



14Likes
LinkBack URL
About LinkBacks



