Reywam / OOP

0 stars 0 forks source link

Замечания по ArraySum #3

Open alexey-malov opened 7 years ago

alexey-malov commented 7 years ago
std::string ArraySum(std::vector<char> const& arr);
alexey-malov commented 7 years ago
template <typename T>
T ArraySum(std::vector<T> const& arr);

template <typename T>
T ArraySum(std::vector<T> const& arr)
{
    T sum = T();

    if (!arr.empty())
    {
        for (auto &element : arr)
        {
            sum += element;
        }
    }

    return sum;
}