Re: "static" question

From: Pat (Pat_at_Pat.com)
Date: 04/19/04


Date: Tue, 20 Apr 2004 00:31:36 +0800

Thanks, Alf.

Pat
"Alf P. Steinbach" <alfps@start.no> ¦b¶l¥ó
news:408289ff.369713562@news.individual.net ¤¤¼¶¼g...
> * "Pat" <Pat@Pat.com> schriebt:
> > I would like to know what is the meaning of :
> >
> > static vector<int> v;
> >
> > What is the difference with:
> >
> > vector<int> v;
> >
>
> That depends on the context of the declaration.
>
> If it is at namespace scope (outside any function or class) then 'static'
> means that v has internal linkage, i.e., in practical terms, is not
visible to
> the linker outside the compilation unit.
>
> If it is in a class or function then 'static' means that v has global
> lifetime; for a class it is a single variable instead of a member variable
in
> each instance of the class; for a function it is a single variable instead
of
> an automatic variable created & destroyed for each call of the function.
>
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?



Relevant Pages

  • Re: extended operators
    ... this one would not reflect the spirit: first simplify C by removing ... maybe more clearly splitting out what is part of the declaration and what is ... context independence, if added, would require either eliminating typedefs, ... dos boot @C. ...
    (comp.std.c)
  • Re: A Grammar Writing Question
    ... complicate the separation of lexing and parsing. ... declaration) from a function call. ... the final context. ... Jim worked through these examples and developed a grammar ...
    (comp.compilers)
  • Re: JavaScript global object
    ... Variables should always be declared using a var statement. ... When control enters an execution context for eval code, ... However, because the function declaration is evaluated using eval, it doesn't exist until execution of that function call. ... The variable, TestEval2, does not exist anywhere within the scope chain of the EvalCode function, therefore assignment will proceed by creating a new global variable, and assigning to it a reference to the new function object. ...
    (comp.lang.javascript)
  • Re: "static" question
    ... > I would like to know what is the meaning of: ... That depends on the context of the declaration. ... lifetime; for a class it is a single variable instead of a member variable in ...
    (comp.lang.cpp)
  • Re: How to access a static member variable within __asm { }
    ... Show the declaration, the context in which you are writing the __asm insertion, and the ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)