- 320 名前:デフォルトの名無しさん mailto:sage [2008/03/04(火) 17:05:25 ]
- >>310
多分、テンプレート関数では配列の一部を出力してその有無を返すだけと判断して勝手に修正してみた。 -- #include <iostream> using namespace std; template<class T> bool show_array(T array[], int N) { for (unsigned ic = 0; ic < N; ++ic) { cout << array[ic] << ' '; } return N != 0; } int main( void ) { int pages[] = { 100, 200, 300, 400, 500 }; float price[] = { 10.05, 20.10, 30.15 }; /* int型の配列 */ show_array( pages, 5 ); cout << '\n'; /* float型の配列 */ cout << show_array( price, 3 ) << endl; cout << show_array( price, 0 ) << endl; cout << '\n'; return 0; }
|

|