the scope of variable
hi,
I was reading C++ Primer,4th and met a problem. In the book, it says the variable has a satement scope,which means if you define a varialbe in a statement such as in for statement, then you cannot use it out of the statement scope.but i worte a little program:
for(int i=0;i<10;i++)
{
do something;
}
cout<<i<<endl; then I complied it ,it works fine. So I cannot understand the statement scope. Can anynoe here help me? Thanks in advance!
|