What are Static member functions ?

Like static member variables, we can also have static member functions. It has the following properties:
  1. A static function can have access to only other static members declared in same class.
  2. A static member function can be called using the class name as follows
Class name :: function name

#include<iostream.h>
class test
{
        int a;
        static int b;
        public:
        void setdata()
       { 
                a=b++; 
        }
       static void showdata()
      { cout<< b; }
 };
void main()
       text x1,x2;
       x1.setdata();
       x2.setdata();
       test::showdata(); 
}

Post a Comment

Previous Post Next Post