in c++
where are static or non-static variables stay? I mean in memory.
and, When are static or non-static variables initialized?
Need someone help me get my thought clear.
Thank you!
and what about C? same?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They can go wherever the compiler (or linker or loader) wants to put them in memory, the C and C++ standards don’t mandate that level of detail. They only mandate the behaviour.
Typically, static members are initialised once, either on program startup (including at compile time so that they’re simply loaded in an already-initialised state) or immediately before first use.