C++ Programs
| PProgram to implement static member data. |
#include<conio.h>
#include<iostream.h>
class item
{
private:
static int count;
int code;
public:
void getcode()
{
cout<<"\nenter code:";
cin>>code;
}
void showcode()
{
cout<<"code is: "<<code;
}
void showcount()
{
cout<<"\ncount is:"<<count;
count++;
}
};
int item :: count;
void main()
{
clrscr();
item a,b;
a.getcode();
a.showcode();
a.showcount();
b.getcode();
b.showcode();
b.showcount();
}
| Output: |
enter code:111
code is: 111
count is:0
enter code:112
code is: 112
count is:1
If any of you want to submit your programs and
contribute to site please mail us at:
citysuvidha@gmail.com
Click here to have a look at List of programs
You can download all the programs in a zip file also. For this you have to do one thing. Just register at the citysuvidha forum and start any thread of any topic. Once you start the thread and put your request, admin will automatically send you the desired zip file.