home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18009 < prev    next >
Encoding:
Text File  |  1992-12-15  |  807 b   |  43 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!uflorida!math.ufl.edu!maple.circa.ufl.edu!X9999BVJ
  2. From: x9999bvj@maple.circa.ufl.edu
  3. Newsgroups: comp.lang.c++
  4. Subject: Static vars in member functions
  5. Message-ID: <1992Dec13.185540.20212@math.ufl.edu>
  6. Date: 13 Dec 92 18:55:40 GMT
  7. Sender: news@math.ufl.edu
  8. Reply-To: X9999BVJ@oak.circa.ufl.edu
  9. Organization: Center for Instructional and Research Computing Activities
  10. Lines: 31
  11.  
  12.  
  13. When calling a function of a class with a static variable declared in it,
  14. what is the standardized behaviour for that variable?
  15.  
  16. E.g.
  17.  
  18. class Foo
  19. {
  20.    public:
  21.       void Blah( void );
  22. };
  23.  
  24. void Foo::Blah( void )
  25. {
  26. static int i;
  27.  
  28.    i++;
  29. };
  30.  
  31. void main( void )
  32. {
  33. Foo a, b;
  34.  
  35.    a.Blah();
  36.    b.Blah();
  37.    a.Blah();
  38. }
  39.  
  40. When the second "a.Blah()" is executed, will i be 2 or 3?
  41.  
  42. Brian
  43.