linkage of object declared outside main

C

Cplusplus

as C++ defaults to external linkage for non-consts and non-static(right?):

Qn) why is it then : a object declared (*without* static keyword)outside
main() and outside all functions , automatically considered a static
object ?. doesn't static mean its internal linkage?
accding me if u define a object like this then A should be external linkage.

Obj A('a'); // Global

int main()
{
blah;
}
 
J

John Harrison

Cplusplus said:
as C++ defaults to external linkage for non-consts and non-static(right?):

Qn) why is it then : a object declared (*without* static keyword)outside
main() and outside all functions , automatically considered a static
object ?. doesn't static mean its internal linkage?
accding me if u define a object like this then A should be external linkage.

Obj A('a'); // Global

int main()
{
blah;
}

I think you are confusing the many meanings of the word static in C++.

Object A has static storage duration but external linkage. If you declared
it with the keyword static then it would still have static storage duration
but internal linkage.

john
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top