+ 2

Why should we define static member variable outside the class?

Static variables are initialized to 0 and defined after class definition. So, why compiler don't show error like "...was not defined in this scope"?

15th Apr 2017, 4:56 PM
Mohit Negi
Mohit Negi - avatar
1 ответ
+ 2
I am not sure If I understand well,but the c++ is not strict object oriented language.In c++ there is a rule you use a variable there you currently need it. It is not necessary construct an object for it which the variable belong as a member.
15th Apr 2017, 5:17 PM
Highman
Highman - avatar