Static Member Functions

Like static member variable, we can also have static member function. A member function that is declared static has the following properties:
  • A static function can have access to only static members declared in the class.
  • A static member function can be called the class name as follows:

class-name :: function-name;

The static function showcount() displays the number of objects created till that moment. A count of number of objects created is maintained by the static variable count.
The function showcode() displays the code number of each object.

No comments:

Post a Comment