You need to make a static class member that holds the next count and shelf, and initialize them statically, rather than initializing them in the constructor...
class book
{
char bno[6];
char bname[50];
char aname[20];
int my_count;
int my_shelf;
static int total_books_count;
static int current_shelf;
book ()
{
my_count = total_books_count;
my_shelf = current_shelf;
total_books_count++;
if (total_books_count == 3)
{
total_books_count = 0;
current_shelf++;
}
}
void create_book()
{
cout<<"\nNEW BOOK ENTRY...\n";
cout<<"\nEnter The book no.";
cin.ignore();
cin.getline(bno,6);
cout<<"\n\nEnter The Name of The Book ";
cin.getline(bname,50);
cout<<"\n\nEnter The Author's Name ";
cin.getline(aname,20);
cout<<"\n\n\nBook Created..";
}
...
}
int book::total_books_count = 0;
int book::current_shelf= 0;
The way you have the code written, every book starts out with it's own count1 = 0 and shelf = 1 and each book thinks it's the only book...