.
Home About-us Privacy Policy Contact-us Services

Thursday, October 8, 2015

C++ Program to increment the number to show the working of static function

ad+1

Program -



#include<iostream.h>
#include<conio.h>
#include<dos.h>
class stu
{
private:
static int c;
public:
stu();
static void write();
};
int stu::c=0;
stu::stu()
{
c++;
}
void stu::write()
{
cout<<"final value of c"<<c<<endl;
}
void main()
{
cout<<"before understanding object"<<endl;
stu::write();
stu m1,m2,m3,m4,m5;
cout<<"after the understanding of object"<<endl;
stu::write();
getch();
}
 
Output :
  
before understanding object
final value of c 0
after the understanding of object
final value of c 5



0 comments:

Post a Comment

Home About-us Privacy Policy Contact-us Services
Copyright © 2014 All Programs Examples | All Rights Reserved. Blogger Templates Download Blogger Templates