Advertisements
Advertisements
Question
Differentiate between static data members and non-static data members.
Distinguish Between
Solution
S. No. | Static data member | Non-static/Ordinary data member |
1. | All class objects share a single copy of this variable. | Each item creates a copy of the data. |
2. | It can be accessed without requiring an instance of the class. | Using it requires first constructing a class instance. |
3. | Static variables are allocated only once during class loading. | Each new object creates additional memory allocations for these variables. |
shaalaa.com
Is there an error in this question or solution?