1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include <iostream> #include <algorithm> using namespace std; template <typename ElementType, int ARRAY_SIZE> void printArray( ElementType const (&array)[ ARRAY_SIZE ], ostream &output = cout ) { for( int index = 0; index != ARRAY_SIZE; ++index ) output << array[ index ] << ' '; output << endl; } int main() { int iArray[] = { 1, 2, 3 }; float fArray[] = { 55.0, 66.0 }; printArray( iArray ); printArray( fArray ); system("pause"); } |
Direct link: https://paste.plurk.com/show/288965