精華區beta ck54th329 關於我們 聯絡資訊
※ 引述《ugoc (打球啦)》之銘言: #include <iostream> using namespace std; void f() { static int x=1; cout<<x++<<endl; if (x-3)f(); } void main() { f(); } // //output: //1 //2 -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: 210.85.118.7
Quezacot:就是硬把他宣告成global variable??? 推 61.224.129.148 11/19
Upsha:和global完全不一樣 推 218.160.17.48 11/19
其實我這樣說不好啦 static是在整個『程式』裡只會被define一次 global是每個.cpp or .h裡面的咚咚 這扯到compile的過程和.h .cpp設計的目的耶... -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: 218.160.17.48