?
A static data member is given a value
Answer & Solution
Correct Answer:
Option
B
Static data members in C++ are special variables associated with a class, not individual objects of that class.
This means there's only one copy of the static member shared by all objects of the class.
Because of this shared nature, you can't initialize them directly within the class declaration like regular member variables.
Instead, you need to give them a value outside the class definition.
This is done typically by providing an initialization outside the class, often in the same header file or a separate source file.
Therefore, the correct answer is that a static data member is given a value outside the class definition.
This means there's only one copy of the static member shared by all objects of the class.
Because of this shared nature, you can't initialize them directly within the class declaration like regular member variables.
Instead, you need to give them a value outside the class definition.
This is done typically by providing an initialization outside the class, often in the same header file or a separate source file.
Therefore, the correct answer is that a static data member is given a value outside the class definition.
Join the Discussion
Login to post a comment or share your explanation.
Login