Page 120 - DCAP404 _Object Oriented Programming
P. 120

Unit 5: Static Members




             Customers WHERE Balance > 50’ tells the database to return information about customers  Notes
             that owe more than $50.”
             Examples of 3GLs are Pascal and FORTRAN, which provided elements such as subroutines,
             loops, and data structures. And the 2GL was assembly language, providing terse mnemonics
             for machine instructions. At the beginning, as you would have guessed by now, was the
             language of 0s and 1s, the machine language. “You actually had to program some early
             computers by painstakingly toggling switches to enter 0s and 1s!”

          Self Assessment


          Fill in the blanks:
          11.  A friend function is declared by the class that is granting …………….. .
          12.  The friend declaration can be placed ………………….. in the class declaration.
          13.  To declare a  friend function, simply use the ………………….. keyword in front of the
               prototype of the function you wish to be a friend of the class.
          14.  A function can be a friend of more than one class at the………………... .
          15.  It is also possible to make an entire class a ………………… of another class.

          5.5 Summary


              Member data items of a class can be static. Static data members are data objects that are
               common to all objects of a class.
              They exist only once in all objects of this class.

              The static members are used when the information is to be shared.
              They can be public or private data. The main advantage of using a static member is to
               declare the global data which should be updated while the program lives in memory.

              A static member function is not a part of objects of class.
              It is instance dependent and can be accessed directly by using the class name and scope
               resolution operator.

              If it is declared and defined in a class, the keyword static should be used only in declaration
               part.
              The friend function is written as any other normal function, except the function declaration
               of these functions is preceded with the keyword friend.
              The friend function must have the class to which it is declared as friend passed to it in
               argument.
          5.6 Keywords


          Friend Function: A function which is not a member of a class but which is given special permission
          to access private and protected members of the class.

          Static Data Members: Static data members are data objects that are common to all objects of a
          class.
          Static Member Functions: Functions that can access only the static members.





                                           LOVELY PROFESSIONAL UNIVERSITY                                   113
   115   116   117   118   119   120   121   122   123   124   125