Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Generics

Name: Anonymous 2012-05-30 15:18

I didn't know C++ generics were this powerful


#include <iostream>
#include <array>

template<typename T, std::size_t N>
void print_members(const std::array<T, N>& arr)
{
    for (auto it = arr.cbegin(); it != arr.cend(); ++it) {
        std::cout << *it << std::endl;
    }
}

int main(int argc, char** argv)
{
    std::array<int, 5> numbers = {{1,2,3,4,5}};
    std::array<char, 5> letters = {{'A','B','C','D','E'}};

    print_members(numbers);
    print_members(letters);

    return 0;
}

Name: Ἀλκιβιάδης 2012-05-31 10:12

>>22
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time
dubs won this time

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List