方法和函式有什麼不同 (Difference between a method and a function )


今天跟同事討論到
Function跟Method 有什麼不同


宣告在類別裡面的是方法(Method) 
獨立於類別之外的是函式(Function)

Functions stand alone and methods are members of a class. 
http://kurtyu1209.blogspot.tw/2011/10/function-method.html


Vitali Kaspler
When a function is a part of a class, it's called a method.
http://stackoverflow.com/questions/12258964/difference-between-method-and-function


A method is on an object.
A function is independent of an object.
For Java, there are only methods.
For C, there are only functions.
For C++ it would depend on whether or not you're in a class.
 methods in C++ are called member functions.
http://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function

好囉大概就這樣子,以我自己的了解做的歸納
廣義來說是一樣的東西 
不一樣的就是在有OOP的地方,
在class裡面,跟物件關聯的就叫做method
但是method也是一種function
所以目前我寫的C#裡也是叫method

留言

這個網誌中的熱門文章

下列模組是在啟用最佳化或沒有偵錯資訊的情況下建置的

[ASP .NET] 組態錯誤 無法載入檔案或組件 System.Web.Extensions 問題

Fileupload 設定成無法自行輸入