✏️ Explanatory Question
Differentiate between static and non-static data members.
-
Static Data Members:
- Shared among all instances of a class.
- Only one copy exists for the entire class, regardless of the number of objects created.
- Accessed using the class name.
-
Non-static Data Members:
- Each object of the class has its own copy of non-static data members.
- They are also known as instance variables.
- Accessed through the object of the class.