home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!gatech!udel!rochester!rocksanne!news
- From: Heliotis.ROCH803@xerox.com (Jim Heliotis)
- Subject: Re: Not supposed to use static variables in me
- Message-ID: <1993Jan5.143723.7928@spectrum.xerox.com>
- Sender: news@spectrum.xerox.com
- Reply-To: Heliotis.ROCH803@xerox.com
- Organization: Xerox Corporation, Webster NY
- References: <ghawkins.725838896@unix1.tcd.ie>
- Date: Tue, 5 Jan 1993 14:37:23 GMT
- Lines: 35
-
- In article 725838896@unix1.tcd.ie, ghawkins@unix1.tcd.ie (George C. Hawkins) writes:
- >
- >If a member function wants to remember a value between calls to it
- >then it must store that value in a varaible visible to all member
- >functions. Is this right? I was doing:
- >
- >class Foo {
- > void bar;
- >}
- >
- >void Foo::bar()
- >{
- > static int remember;
- >
- > // etc.
- >}
- >
- >But was rather upset to find that all instances of Foo shared the
- >same 'remember'.
-
-
- I have not yet seen the answer to this question that I consider most
- straightforward. You should declare "remember" as a member variable
- (non-static). The only disadvantage to that, possibly, is that any
- member function can access it that way.
-
-
- ============================================================================
- Jim Heliotis Voice Phone: 716-383-7410
- Xerox Corporation FAX Phone: 716-383-7395
- 435 W. Commercial St. Mail Stop: 803-01A
- East Rochester, NY 14445 Electronic Mail: JEH.ROCH803@Xerox.COM
- ============================================================================
-
-
-