void includebook()
{
book*newbook=new book();
author*newauthor=new author();
newbook->name=getstring("Enter name of the book you want to enter");
newauthor->name=getstring("Enter the name of author who wrote this book");
list<author*>::iterator oldauthor=findit(catalog[newauthor->name[0]],*newauthor);
if(oldaauthor==catalog[newauthor->name[0]].end())
newauthor->books.push_front(newbook);
catalog[newauthor->name[0]].push_front(newauthor)
else
(*oldauthor)->books.push_front(newbook);
}
HI All,
Please find necessary definitions to understand the above code.
The above includebook() function has to include a book into a library,it searches if author exist if he exists it adds a book into the list author already has.If author doesnt exist then it adds new author into the list and add this cuurent book as his first book.
Now My doubts are:
1)List<author*>catalog['Z'+1];what does this mean? what is 'Z' doing?
2)In Includebook() function
while catalog is a list whey are they accessing it randomly with [] subscript while random access is not allowed in List? catalog[newauthor->name[0]];
and why are they using just the first letter of authir;s name(newauthor->name[0])rather than full name for this search?