include "stdafx.h"
#include <vector>
#include <iostream>
int main( int argc, char* argv[] )
{
std::vector< int > data( 5 );
data[ 0 ] = 0;
data[ 1 ] = 1;
data[ 2 ] = 2;
data[ 3 ] = 3;
data[ 4 ] = 4;
int total = 0;
for ( std::vector< int >::iterator it = data.begin(); it != data.end(); it++ ) {
int value = *it;
total += value;
}
std::cout << total << std::endl;
total = 0;
for each ( const int i in data ) {
total += i;
}
std::cout << total << std::endl;
return 0;
}
|