method Vs function

I'm a little (or a lot?) confused as to what the difference is, if they are indeed different, between a method and a function in C++.

When someone says write a method that does this and that is it the same as saying write a function?
A method is a "member function" of a class.
Functions stand alone and methods are members of a class. That's all. (I personally despise the term method but it's really all the same.)
and what is a function?

If you simply say function then it could appear anywhere, including outside of a class?

So a method IS a function but a function NOT NECESSARILY a method?
Clear. Thanks!
In the most technical of meanings, method != function and function != method, ever.
Well,

(method <= function) and function !(function<=method)

where "<=" is a special ordering operator with the definition quite obvious.

This contains more information than (method!=function).
Last edited on
Function: a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code.
Member function (or "method" in OOPese): a function that is a member of a class. The membership gives it special properties global functions don't have, such as being in a different namespace (that of the class), and taking an implicit this parameter (only for non-static member functions).

Member function ⊂ function.
Topic archived. No new replies allowed.