finding the sum of array class

I'm confused on how I can find the sum of the array
1
2
3
4
5
6
7
  DollarAmount sum(DollarAmount a[], int size){ // calculates the sum of the Array of dollars
    DollarAmount s;
    for(int x=0; x<size; x++){
        s=s+a[x];
    }
    return(s);
}
DollarAmount s = 0; or C++11 DollarAmount s { };

s += a[x];

Topic archived. No new replies allowed.