I have a cpp program which takes some double values as input and calculate the total of the values. Length of the array is not stable. It changes with the number of input. So I chose to use for each loop inside the function.Following is my code.
double getTotal (double arr[]){
   double total = 0;
   for (double x : arr){
      total += x; 
   }
   return total;
}
The above code gives me the following error
main.cpp: In member function ‘double My1DArray::getTotal(double*)’:
main.cpp:39:28: error: ‘begin’ was not declared in this scope
        for (double x : arr){
                        ^
I tried to use arr.size() which gave me a bunch of errors.
What cause the problem?
