473,385 Members | 1,275 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

<numeric> accumulate won't accept three inputs

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
2 1165
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Dave | last post by:
Hello all, Is is allowable for me to specialize numeric_limits<> for my own numeric type? Does this violate any sort of rule against mucking with std? Thanks, Dave
9
by: Ragnar | last post by:
Hi I have one question regarding Tidy (http://tidy.sourceforge.net). My source XML-file has got a lot of unclosed <BR>-tags. Which command do I need (in my tidy config-file) to close it <BR/and...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
1
by: Jacek Dziedzic | last post by:
Hello! This is my first time dealing with Very Large Files. I have vector of strings representing numbers and I need to extract bytes in binary mode from a Large File that correspond to...
13
by: Mark | last post by:
Dear folks, In Javascript, is it possible to get all id names within, say, a <div></divpair? Like the array of "document.images", I mean. The reason I ask, is that I have a calender whose...
7
by: Christian Hackl | last post by:
Hi everyone, I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the...
0
by: Ethan Furman | last post by:
Greetings, List! Still working on my Measure class, and my next question is... (drum roll please ;) What are the advantages of using ____ vs __cmp__? Thanks in advance! -- Ethan
0
by: Gabriel Genellina | last post by:
En Thu, 10 Jul 2008 17:37:42 -0300, Ethan Furman <ethan@stoneleaf.us> escribi�: If your objects obey the trichotomy law (an object MUST BE less than, greater than, or equal to another one,...
36
by: Roedy Green | last post by:
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.