看板 ck55th307 關於我們 聯絡資訊
#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; cout << "and then the count after TBV working = " << count << endl; cout << "\nresult done by TBR = " << TripleByReference( count ) << endl; cout << "and then the count after TBR working = " << count << endl; return 0; } int TripleByValue( int x ) { x = x * 3; return x; } int TripleByReference( int &y ) { y = y * 3; return y; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.18.100
mamalo:自以為perfect 推 140.112.18.101 11/05
YCTai:這...純粹就練習指標? 推 61.222.126.236 11/05