View Single Post
  #5 (permalink)  
Old January 9th, 2009, 11:51 PM
DrPurdum DrPurdum is offline
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default

"Also, all static data are defined the instant the program is loaded into memory.

I know this is just a slip of the wording. Static data is of course *reserved* when the program is loaded into memory. But it won't be "defined" (that is, contain usable data) until something in your program initializes it. [The exceptions are static initialized members, of course.]
"

Actually, it is not a "slip of the wording". Any static is defined the moment the program is loaded into memory. It has an lvalue (an allocated memory address) and it is automatically initialized to zero if it's a value type or null if it's an object, or whatever values are in the initializer list, if there is one. The words "define" and "declare" have very different meanings and statics truly are defined at load time.

I stand by what I say both here and in the book, especially for the readership of the book. I learned long ago that students ask questions for one of several reasons. One, they genuinely want to learn the answer to the question or, two, they already know the answer to the question and just want to show off for everyone else in the class. Teachers love the first type of questions. The second type...not so much.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)