linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* various meanings of static
@ 2007-06-23  6:08 Shriramana Sharma
  2007-06-23 12:55 ` Darío Mariani
  0 siblings, 1 reply; 6+ messages in thread
From: Shriramana Sharma @ 2007-06-23  6:08 UTC (permalink / raw)
  To: Linux C Programming List

Hello.

To my thinking, the keyword static is used for four different purposes 
in C++. I will explain this and I request your comments on that:

1. "static" is used in the declarations at file scope of variables and 
functions to make them "local" -- i.e. visible only within that file.

2. "static" is used in the declarations of variables inside functions to 
make them "sticky" -- i.e. not get destroyed when the function is exit. 
They "stick" around.

3. "static" is used in the declarations of variables inside classes to 
make them "classwide" -- i.e. common to all instances of that class, in 
contrast with other member variables which are unique to each instance.

4. "static" is used in the declarations of functions inside classes to 
make them "nothis" -- i.e. not take/require a silent "this" pointer to 
be passed, and hence be able to be called without an instance of that 
class to exist.

I am thinking of using # define-s to use these four words:

local, sticky, classwide, nothis

instead of static in my C++ programs to make them more meaningful. I 
believe that the above four are mutually distinct purposes of the single 
static keyword and whether a future C++ standard disambiguates these 
purposes or not (where I prefer it would) I can even now use these new 
clearer keywords.

Are there any other meanings to static? Or are there any objections to 
the above classification?

Thank you.

Shriramana Sharma.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-06-25 23:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-23  6:08 various meanings of static Shriramana Sharma
2007-06-23 12:55 ` Darío Mariani
2007-06-23 16:11   ` Glynn Clements
2007-06-24 21:08     ` Pedro de Medeiros
2007-06-25 21:35       ` Glynn Clements
2007-06-25 23:01         ` Pedro de Medeiros

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).