View Single Post
  #1 (permalink)  
Old October 21st, 2006, 10:21 PM
ccj_999 ccj_999 is offline
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!

Reply With Quote