home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:13517 gnu.g++.help:1217
- Path: sparky!uunet!dtix!darwin.sura.net!wupost!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!ai-lab!prep.ai.mit.edu!gnulists
- From: steve@taumet.com (Steve Clamage)
- Newsgroups: comp.lang.c++,gnu.g++.help
- Subject: Re: Variable Declarations
- Keywords: variables, constructors
- Message-ID: <gnusenet1992Sep10.170948.641@taumet.com>
- Date: 10 Sep 92 17:09:48 GMT
- References: <u895217.716089910@bruny>
- Followup-To: comp.lang.c++,gnu.g++.help
- Organization: TauMetric Corporation
- Lines: 21
- Approved: info-gnu@prep.ai.mit.edu
- To: gnu-g++-announce@uunet.uu.net
-
- u895217@bruny.cc.utas.edu.au (Scott Marshall) writes:
-
- |I need a little advice on using C++. When given the following code, would
- |the variable being declared (and initialised) be re-initialised on every
- |iteration?
-
- | char buf[whatever];
- | f.getline(buf, whatever);
- | while (buf[0] != '#') {
- | String s = buf;
- | if (s.contains("int") ...
- | else ...
- | f.getline(buf, whatever); }
-
- Local object 's' will be newly constructed at the top of the loop
- for each iteration, and destroyed at the bottom of the loop. The
- braces make a new scope and ensure these semantics.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-