May 2012
Intermediate to advanced
679 pages
16h 56m
English
After studying public and private members, let us study qualifier “static” with reference to a class. We can have static data members as well as static methods. Let us study them in detail.
We have already seen that only data members are instantiated in every object. However, sometimes a data member has to have the same value for all the objects of that class. For example in class Player, logo remains the same irrespective of any instantiation of the class. The player may be Sachin or Sourav; the logo is “sahara”.
Like ordinary members, we can refer these static members with dot mechanism like sachin.logo.
If we have to reference it with the help of class name, we must use (::) operator. ...
Read now
Unlock full access