Difference between function and method? [duplicate]

拜拜、爱过 提交于 2019-12-23 05:34:14

问题


Possible Duplicate:
method vs function vs procedure vs class ?

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


回答1:


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




回答2:


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

also see here




回答3:


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



来源:https://stackoverflow.com/questions/3280005/difference-between-function-and-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!