看板 ck55th307 關於我們 聯絡資訊
<<是什麼我沒用過.. 讓他倒著跑嗎 ※ 引述《BGrap (smoke the mic)》之銘言: : ※ 引述《BGrap (smoke the mic)》之銘言: : : #include <iostream> : : using std::cout; : : using std::cin; : : using std::endl; : : int TripleByValue( int ); : : int TripleByReference( int & ); : : int main() : : { : : int count; : : cout << "Enter an integer" << endl; : : cin >> count; : : cout << "result done by TBV = " << TripleByValue( count ) << endl : : << "and then the count after TBV working = " << count << endl : : << "\nresult done by TBR = " << TripleByReference( count ) << endl : : << "and then the count after TBR working = " << count << endl; : : return 0; : : } : : int TripleByValue( int x ) : : { : : int z; : : z= x*3; : : return z; : : } : : int TripleByReference( int &y ) : : { : : y = y*3; : : return y; : : } : : ------------------------------------------- : : work out : : Enter an integer : : 4 : : result done by TBV = 36 : ^^^^^^^^^^^^^^^^^^^^^^^^^ : 這個為什麼是36 我要的是12 : : and then the count after TBV working = 12 : : result done by TBR = 12 : : and then the count after TBR working = 4 : : Press any key to continue -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.115.137