Your Ad Here

Monday, February 4, 2008

Static Data members

/* C++ program For the IMPLEMENTATION OF STATIC DATA MEMBERS */

#include< iostream.h>
#include< conio.h>
class book
{
private:
static int count;
int bookid;
public:
addbook(void)
{
count ++;
bookid=count;
}
displaybook()
{
cout< < "The Number Of The Books Are:"< < count;
}
};
int book::count;
void main()
{
book b1,b2;
clrscr();
b1.addbook();
b2.addbook();
b1.displaybook();
cout< < endl;
b2.displaybook();
getch();
}

/* OUTPUT
The Number Of The Books Are:2
The Number Of The Books Are:2
*/

3 comments:

Keser Singh said...

Ok thanks its working

Anonymous said...

can i get the algorithm for the program

Anonymous said...

algorithm please

Your Ad Here