Hello ladies and gents,
I'm reading about the algorithm partial_sum and there are two different versions of this.
The first one just calculates cumulative numbers like this:
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
int a[4] = {10, 20, 30, 40}, b[4];
partial_sum(a, a+4, b);
copy(b, b+4, ostream_iterator<int>(cout, " "));
cout<<endl;
cout<<"Press any key to continue!\n";
cin.get();
return 0;
}
The second one can be used for other algorithmetic reasons, like multiplying for example:
#include <iostream>
#include <numeric>
#include <list>
using namespace std;
int main()
{
long a[4] = {10, 20, 30, 40}, b[4];
partial_sum(a, a+4, b, multiplies<long>());
copy(b, b+4, ostream_iterator<long>(cout, " "));
cout<<endl;
cout<<"Press any key to continue!\n";
cin.get();
return 0;
}
The questions I have though are:
1) I can't seem to be able to use the second version with #include <vector>, why is that?
2) How can I know wich header file is exactly needed for this?