P
Pat
I would like to know what is the meaning of :
static vector<int> v;
What is the difference with:
vector<int> v;
static vector<int> v;
What is the difference with:
vector<int> v;
* "Pat said:I would like to know what is the meaning of :
static vector<int> v;
What is the difference with:
vector<int> v;
Alf P. Steinbach said: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?
* "Fraser Ross said:* "Alf P. Steinbach"
Thats wrong.
A static object of a class in a function will be constructed
only with the first call of the function
and destructed only when the
program terminates although it might not be destructed with some abnormal
terminations.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.