By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,490 Members | 3,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,490 IT Pros & Developers. It's quick & easy.

<numeric> accumulate won't accept three inputs

P: n/a
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();
}


Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
double average(const list<double>& l){
return accumulate(l.begin(), l.end, 0.0) / l.size(); //Error: missed params
}

Must be

double average(const list<double>& l){
return accumulate(l.begin(), l.end(), 0.0) / l.size();
}
--
Un saludo
Rodrigo Corral GonzŠlez [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
Nov 17 '05 #2

P: n/a
Thank you very much. I stared at the code, looked at examples, looked on the
web, etc. The answer was very obvious, but I just didn't see it. Thank you
for your reply and your time.

Saludos,
Ben R

"Rodrigo Corral [MVP]" wrote:
double average(const list<double>& l){
return accumulate(l.begin(), l.end, 0.0) / l.size(); //Error: missed params
}

Must be

double average(const list<double>& l){
return accumulate(l.begin(), l.end(), 0.0) / l.size();
}
--
Un saludo
Rodrigo Corral Gonz√°lez [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.