home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++,gnu.g++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Variable Declarations
- Message-ID: <1992Sep10.170948.641@taumet.com>
- Keywords: variables, constructors
- Organization: TauMetric Corporation
- References: <u895217.716089910@bruny>
- Date: Thu, 10 Sep 1992 17:09:48 GMT
- Lines: 21
-
- 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
-