Summing function of accumulate C ++ STL ()
1.1 Description and function prototypes
accumulate(_InIt _First, _InIt _Last, _Ty _Val)
_First
And _Last
accumulation interval, _Val
the accumulated initial values.
The return type with _Val
the same.
1.2 int application
And an output array
vector<int> testArray = { 1, 2, 3, 4 };
int sumT = accumulate(testArray.begin(), testArray.end(), 0);
1.2 string in the application
The char type is string type splicing
vector<char> testChr = { 'l', 'h', 'k' };
string strSum = accumulate(testChr.begin(), testChr.end(), (string)" "); \\sunT = "lhk"