c++ for_each() and object functions
<p>I have an assignment that is the following:</p>

<p>For a given integer array, find the sum of its elements and print out the final
result, but to get the sum, you need to execute the function for_each() in STL
only once (without a loop).</p>

<p>As of now this is my code:</p>

<pre><code>void myFunction (int i) {
cout &lt;&lt; " " &lt;&lt; i &lt;&lt; " " &lt;&lt;  endl;
} 


int main() {

int array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

vector&lt;int&gt; v(array[0], array[10]);

for_each( v.begin(), v.end(), myFunction);

return 0;
}
</code></pre>

<p>But for some reason the output shows up as 4198853, at first I thought it was a memory address but I figured out that was wrong. Any idea's as to what I might be doing wrong?</p>
