0

Possible Duplicate:
method vs function vs procedure vs class ?

Can some one give the differences between a method and a function?

Community
  • 1
  • 1
RK-
  • 12,099
  • 23
  • 89
  • 155
  • i suggest you to read at [this link](http://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function?rq=1). 1) A **function** is a piece of code that is called by name 2) a **method** is a piece of code that is called by a name that is associated with an object. to it is implicitly passed the object on which it was called. – Gabrio Dec 02 '16 at 12:33

3 Answers3

3

Both are the same. Both are subroutines and both can return a value. Only difference may be the attachment to class. Method sounds more attached to a class but again, people use to call the non attached ones too methods. So, in that aspect too they can be seen as same

bragboy
  • 34,892
  • 30
  • 114
  • 171
2

In java, and c++, by convention a function is called a method if it is member of a class.

also see here

sum1stolemyname
  • 4,506
  • 3
  • 26
  • 44
0

In many languages methods don't return values while functions do.

Johann Strydom
  • 1,482
  • 14
  • 18
  • Subroutines which do not return values are called procedures by some. The definition of a method does not specify wether or not a value is returned. – sum1stolemyname Jul 19 '10 at 12:25