The problem is that your inputbook() function is using recursion to fill data into a locally scoped copy of the object. As soon as each iteration of the recursion returns, that book "book_number" is going to go out of scope.
You are much better off using a while loop and an array in this situation (or create a second class called library which contains the list of books). Have you gone over dynamic allocation of arrays or linked lists at this point?
If the answer is no, then just make sure that your array is large enough for most use-cases.
OK, let's not get into dynamic memory just yet (it will be desirable later). How comfortable are you with loops and arrays?
Here's a thought of what things might look like, inputBook() should only deal with loading information of a single book, it doesn't need to know that there are any other books in existence in order to exist.
1 2 3 4 5 6 7 8
void book::inputbook()
{
// I'm not a fan of this syntax, but I understand the thought-organization you are using
cout << "\n\nEnter Book Number: "; cin >> this->booknumber;
cout << "Enter Book Title: "; cin.ignore(); getline (cin, this->booktitle);
cout << "Enter Book Author: "; getline (cin, this->bookauthor);
cout << "Enter Date of Publicaiton: "; cin >> this->bookpublish;
}
int main()
{
book library[1024]; // until you get into dynamic memory, just allocate plenty of books
int cursor = 0;
int choice;
// output your menu
cin >> choice;
while(choice != 4 && cursor < 1024)
{
switch(choice)
{
case 1:
// if choice is to add a book:
library[cursor].inputBook();
cursor ++;
break;
}
// Output your menu
cin >> choice;
}
}