Write a program which gives the example of static function in C++?



#include<iostream.h>
#include<conio.h>
class a
{
static int c;
public:
static void a1()
{
c++;
}
static void a2()
{
cout<<"\nafter increment c is\n"<<c;
}
};
int a::c=5;
void main()
{
clrscr();
class a obj;
a::a2();
a::a1();
a::a2();
getch();
}



 OUTPUT:-

after increment c is
5
after increment c is
6











Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart