Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/26/02 22:59
Read: times


 
#33243 - RE: local global???!!!?!?!?!
"It ["local global"] is expression used by professional programmers"

I've never heard it!

"(all global variables are static i.e they keep their value when the function expires)."

Yes, but not all static variables are global!

Variables defined at file scope (ie, outside all functions in a file) are, by default, global (ie, accessible outside the file). However, you can limit their scope to only the defining file by use of the static keyword; the symbol is then inaccessible outside the file.

Variables defined at an inner scope (eg, within a function) are never accessible outside that scope - even if they are static (note the distinction between "scope" and "lifetime" of a variable).

"They define it global but they treat it as local i.e. they never access it from the outside directly."

In that case, they should not define it as global!

As I said before, always define your variables in the innermost scope possible/practical.
It also helps with overlaying.

List of 24 messages in thread
TopicAuthorDate
C++ style in C            01/01/70 00:00      
RE: C++ style in C            01/01/70 00:00      
RE: C++ style in C            01/01/70 00:00      
RE: C++ style in C            01/01/70 00:00      
RE: C++ style in C            01/01/70 00:00      
RE: C++ style in C            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C/ Erik            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C/ Erik            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. //Judy / Erik            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      
RE: C++ style in C. Erik            01/01/70 00:00      
RE: local global???!!!?!?!?!            01/01/70 00:00      
RE: local global???!!!?!?!?!            01/01/70 00:00      
RE: local global???!!!?!?!?!            01/01/70 00:00      
RE: C++ style in C            01/01/70 00:00      
RE: C++ style in C. mahmood            01/01/70 00:00      

Back to Subject List