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 26 27
|
#include <iostream>
#include <array>
template <typename T, std::size_t SIZE>
void dispArray(const std::array<T, SIZE>& input);
int main()
{
std::array<int, 7> arr1 = { 1, 2, 3, 4, 5, 6, 7 };
std::array<short, 6> arr2 = { 2, 4, 6, 8, 10, 12 };
std::array<double, 9> arr3 = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9 };
dispArray(arr1);
dispArray(arr2);
dispArray(arr3);
}
template <typename T, std::size_t SIZE>
void dispArray(const std::array<T, SIZE>& input)
{
for (size_t loop = 0; loop < input.size(); loop++)
{
std::cout << input[loop] << ' ';
}
std::cout << '\n';
}
|