The initial value to a static member variable is done outside the class. Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The initial value to a static member variable is done outside the class. Why?

The initial value to a static member variable is done outside the class. Why?

25th Feb 2017, 10:26 AM
Srikanth Srinivasan
Srikanth Srinivasan - avatar
1 Answer
0
Creating a static member within a class states that any objects associated with that class with contain the same value for the static member in every object. You can not initalize a static member within a class, but in an object. Therefore, being able to alternate it along any other objects.
15th Jul 2018, 1:45 PM
MeeoSlammer