I am not confused, not by far. I am fully aware of what static keyword is used for. This thread start on one simple issue:
ClassX instance; // c style global
and
ClassX ClassX::m_Instance; // c++ static member
The first was called "ugly" compared to the second. I clearly ruled out the rest of the static keyword usage in my first post, and referred to this one specific situation which the topic was about, if you actually take the time to read it, you will notice.
Adding the rest of the static keyword implications into the topic for the sake of arguing or showing off your knowledge of the static keyword has the same relevance as throwing into the discussion the concept "static ip address". I could write up two pages two blabbering about the difference between static ip address and dhcp allocated one, and call you "ignorant" and "confused". But would be pointless. That's exactly what you did listing up the static keyword usage options.
By the way, static keyword usage for scope control is C, not C++, that's why is considered "deprecated" in C++. Looks like you're the one that's confused. To sum up all your examples, is very simple, and maybe this will actually help you too and others to understand: all static variables have memory reserved on data segment (as opposed to heap/stack). This includes global static and local static. Global variables (are also static by definition) are initialized before main is executed (this implies constructors calls if we're talking about objects) and destructed after main ends. Local static are different in terms that are initialized the first time are encountered in code execution (using local static instead of globals doesn't do anything else but delay initialization until first time actually used, and of course, limit the visibility due to block visibility rules in both c and c++). But the memory is STILL reserved at link time. Oh ye, you also seem very confused about the difference between compiler and linker. No space allocation/reservation happens at compile time EVER in any c/c++ compiler, but is done during link time for static variables. By the way, obviously you had no clue that you can actually define static variables in libraries too? WHat's even more cooler, in dll's initialization (again, including constructor calls) happen before even dll main is called for gobals!
Frankly globals/local static init time, as well as the new word you learned this week, "singleton" is one of the very basic issues in the c++ language (and any other oop language for that mater), I don't get why would you fill up pages to show off basic knowledge, or why do you consider it "top skillz" that no one else but you can have it. Even the french guy knows what he's talking about, and fully understand the keyword "static" in all his usage scenarios, he just pointed out that c globals are "ugly", but doesnt know enough english to go into flaming fun tho :P
See? Isn't this annoying? I just repeated what you said, in a different format, or added new things that were never brought up, added a few "you're confused", "I am so cool, you're such a clueless idiot" , "of course you didn't knew *that*", here and there between the lines, and voila, click submit! I will be away for a few days, so unfortunately you win this little friendly flaming war by forfeit, was fun tho
