[問題] uses of the keyword static

看板C_and_CPP作者 (Up2u)時間9年前 (2016/05/08 14:37), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/3 (看更多)
想請問BC是甚麼意思 感恩~~ http://goo.gl/6tgJR Static 6. What are the uses of the keyword static? This simple question is rarely answered completely. Static has three distinct uses in C: (a) A variable declared static within the body of a function maintains its value between function invocations. (b) A variable declared static within a module[1], (but outside the body of a function) is accessible by all functions within that module. It is not accessible by functions within any other module. That is, it is a localized global. (c) Functions declared static within a module may only be called by other functions within that module. That is, the scope of the function is localized to the module within which it is declared. Most candidates get the first part correct. A reasonable number get the second part correct, while a pitiful number understand answer (c). This is a serious weakness in a candidate, since they obviously do not understand the importance and benefits of localizing the scope of both data and code. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.139.97.127 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1462689458.A.F0B.html

05/08 14:49, , 1F
05/08 14:49, 1F

05/08 15:20, , 2F
其實這個我看了中文還是不太懂QQ
05/08 15:20, 2F
文章代碼(AID): #1NBjwoyB (C_and_CPP)
文章代碼(AID): #1NBjwoyB (C_and_CPP)