What is a static data member in C++?
18 views
- A data member that is declared as static in a class. (Correct Answer)
- A data member that is declared as const in a class.
- A data member that is declared as volatile in a class.
- None of the above.
Explanation
Correct answer: a) A data member that is declared as static in a class.
Explanation: A static data member in C++ is a data member that is shared by all instances of a class. It is declared using the static keyword, and its value is initialized only once, when the class is first loaded.