I’d like to highlight my variables that are only valid inside the scope of a loop. In the following example it would be “i” and “pntr” respectively.
for( int i = 0; i < 10; i++ ){
double some_value = i - i*i/2. + i*i*i/6.;
std::cout << i << ": " << some_value << std::endl;
}
for( std::vector<MyClass>::const_iterator pntr = myVector.begin(); pntr != myVector.end(); pntr++ ){
someFunction(*pntr);
}
while( int i = getValue(n) ){
std::cout << i << " ";
if( i > 10 ) break;
}
Is this possible? If yes, how?