vector的简单函数
请问下我明明写的是double型的怎么结果却是int的本人用的是VC#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<double> dou;
double result;
double element;
while(cin>>element)
dou.push_back(element);
double sum(vector<double>::iterator,vector<double>::iterator);
result=sum(dou.begin(),dou.end());
cout<<"result="<<result<<endl;
return 0;
}
double sum(vector<double>::iterator beg,vector<double>::iterator end)
{
int sum=0;
for(;beg!=end;++beg)
sum+=*beg;
return sum;
}