TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: THOMAS MAEDER
from: WIM VELDHUIS
date: 1997-03-31 22:52:00
subject: STATIC? SAY WHAT?

Thomas Maeder wrote in a message to Neil Heller:
NH> TM> The keyword "static" is used for two purposes in C++.
NH> TM> 1. in class declarations to declare class methods/attributes.
NH> TM> 2. in implementation files to prevent the name of a function/
NH> TM>    variable/constant from polluting the global namespace.
NH> I think maybe there are three, as can be seen by the replies I've
NH> already gotten.
 TM> No,  these  are  the  two possibilities. It's just the
 TM> wording that is different.
How about
int Counter()
{
  static int i = 0;
  return i++;
}
This does not limit the scope of i, but changes its lifetime. 
In other words
3. to change the life time of a local variable in a function.
mvg/wr
  
--- timEd/2 1.01.g3+
---------------
* Origin: LightHouse BBS ==> I am a H.U.G.O. Member ! (2:285/324.3)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.