/* C++ Program For the IMPLEMENTATION OF STATIC MEMBERS FUNCTIONS */
#include< iostream.h>
#include< conio.h>
class customer
{
private:
static int count;
int accountno;
public:
void setaccountno(void);
void displayaccountno(void);
void static displaycount(void);
};
int customer::count;
void customer::setaccountno(void)
{
count++;
accountno=count;
}
void customer :: displayaccountno(void)
{
cout< < "The Account Number Is:"< < accountno< < endl;
}
void customer :: displaycount(void)
{
cout< < "The Total Numer Of Account Are:"< < count< < endl;
}
void main()
{
customer c1,c2;
clrscr();
c1.setaccountno();
c2.setaccountno();
c1.displayaccountno();
c2.displayaccountno();
c1.displaycount();
getch();
}
/********* OUTPUT *************
The Account Number Is:1
The Account Number Is:2
The Total Numer Of Account Are:2
*/
Monday, February 4, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
#include
#include
class book
{
private:
static int count;
int bookid;
public:
addbook(int id)
{
bookid=id;
count++;
}
diplay()
{
cout<<"the no. of the book are "<<count;
}
};
int book::count;
void main()
{
book b1,b2;
clrscr();
b1.addbook(3);
b2.addbook(4);
b1.display();
cout<<endl;
b2.diplay();
getch();
}
Post a Comment