From: Vik Heyndrickx Newsgroups: comp.os.msdos.djgpp Subject: Re: Trouble with bools Date: Fri, 24 Oct 1997 10:55:45 +0200 Organization: University of Ghent, Belgium Lines: 20 Message-ID: <34506291.4CB@rug.ac.be> References: NNTP-Posting-Host: eduserv1.rug.ac.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk H. Anthony Hoyt wrote: > > Does this work > > for (auto int i = 0 ; i < 640 ; i++) > for (auto int j = 0 ; j < 480 ; j++) > scrn[i][j] = 0; > > What I know about "auto" is that once you are out of scope (for every new > "i" value) "j" will be destroyed then recreated. Conceptually, you are right. But that is not what the compiler effectively does. The variable j gets assigned an address and every instance j gets this same address. The code you get is the same when you would declare i and j outside the loop. -- +----------------+ | Vik Heyndrickx | +----------------+