Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program that provides an example of static variables in class

Posted By: Adelisa Fischer     Category: C++ Programming     Views: 7224

Write a program that provides an example of static variables in class.

Code for Program that provides an example of static variables in class in C++ Programming

#include<iostream.h>
#include<conio.h>
class stat
{
    staticint count;
    int no;
    public:
        void cnt()
        {
            cout<<"Count = "<<count<<endl;
            count++;
         }
         void num()
         {
            no=1;
            cout<<"Number is = "<<no<<endl;
         }
};
int stat::count=1;

main()
{
    clrscr();
    stat d,e;
    for(int i=0;i<5;i++)
    {
        d.cnt();
        e.num();
    }
}
  
Share: 



Adelisa Fischer
Adelisa Fischer author of Program that provides an example of static variables in class is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!