C++ program of Static Member Function

      No Comments on C++ program of Static Member Function

Program of Static Member Function

C++ Simple program of Static Member Function

Static keyword is used for declaring member function as a static. It can be called using the class name.

#include<iostream.h>
#include<conio.h>
class scan
{
private:
 static int x;
 public:
 scan()
  {
   x++;
  }
 static void display()
  {
   cout<<"x = "<<x<<endl;
  }
};
int scan::x=0;
void main()
{
clrscr();
 scan s1;
 scan::display();
 scan s2;
 scan::display();
 scan s3;
 scan::display();
 getch();
}

OUTPUT:-

Static Member Function


Comment below if you are facing any problem


Also read

C++ program to print 3×3 matrix using class
C++ Simple Program of Static Data Member
C++ Program to add two numbers by defining function Outside the class
C++ program to print alternate elements from an array
C++ program to Insert an element Into sorted array


Summary
C++ program of Static Member Function
Article Name
C++ program of Static Member Function
Description
The program illustrate the concept of Static Member Function.Static keyword is used for declaring member function as a static.
Author
Publisher Name
Scanfcode
Publisher Logo

Leave a Reply

Your email address will not be published. Required fields are marked *