Pages

Difference between static data members and non static data members:

Difference between static data members and non static data members:

             Static data members
             Non Static data members
  1. static data members are declared with static modifier.
  1. Non static data members are declared without  static modifier
  1. Static data members are created in class memory
  1. Non Static data members are created in object memory
  1. We can access static data members by using class name or by using reference pointing object or pointing to null.
  1. We can access non static members only using object or object pointing to reference.
  1. Static data is common for all objects
  1. Non static data is specific for each and every object
  1. Static variables are called class variables.
  1. Non static variables are called as instance variables or object variables.
  1. Static data can be access in both static and non static methods.
  1. Non static data can be access only in non static methods.