G
Guest
I am trying to use the std::accumulate function. When I compile the
following code I get: error C2780: '_Ty
std::accumulate(_InIt,_InIt,_Ty,_Fn2)' : expects 4 arguments - 3 provided.
It should accept three inputs as I've used below. I don't understand. I'd
really appreciate it if someone could set me straight. I've looked at the
declaration in numeric, there is a three input template as I've used. Also
in the help files included with MS VC++ there is an example as I've used the
function. I don't get it! Thanks in advance for any time and help you can
provide. I am using MS VC++ Version 7.1.3088 with .NET Framework ver.
1.1.4322 SP1
#include <iostream>
#include <numeric>
#include <list>
using namespace std;
double average(const list<double>&);
int main(){
list<double> lInput;
double dInput;
while(cin >> dInput){
lInput.push_back(dInput);
cout << "Average so far: " << average(lInput) << endl;
}
return 0;
}
double average(const list<double>& l){
return accumulate(l.begin(), l.end, 0.0) / l.size();
}
following code I get: error C2780: '_Ty
std::accumulate(_InIt,_InIt,_Ty,_Fn2)' : expects 4 arguments - 3 provided.
It should accept three inputs as I've used below. I don't understand. I'd
really appreciate it if someone could set me straight. I've looked at the
declaration in numeric, there is a three input template as I've used. Also
in the help files included with MS VC++ there is an example as I've used the
function. I don't get it! Thanks in advance for any time and help you can
provide. I am using MS VC++ Version 7.1.3088 with .NET Framework ver.
1.1.4322 SP1
#include <iostream>
#include <numeric>
#include <list>
using namespace std;
double average(const list<double>&);
int main(){
list<double> lInput;
double dInput;
while(cin >> dInput){
lInput.push_back(dInput);
cout << "Average so far: " << average(lInput) << endl;
}
return 0;
}
double average(const list<double>& l){
return accumulate(l.begin(), l.end, 0.0) / l.size();
}