# include & ltvector & gt
Use namespace std
# include & ltstring.h & gt
//books
Class c books
{
Public:
Int m _ ID// number
charm _ name[200]; //Book title
Floatm _ price// price
Public:
CBook(int _ID,char* _name,float _ price = 0.0f);
Public:
Void display (); //output
};
CBook::CBook(int _ID,char* _name,float _price)
{
This-> m _ ID = _ ID
strcpy(this-& gt; m_name,_ name);
This-> m _ price = _ price
}
void CBook::Display()
{
printf("%d\t%s\t%.2f\n ",this-& gt; M_ID, this->; M_name, this-> m _ price);
}
Typedef vector & ltCBook * & gtBOOKARRAY
//Library management class
CBookManager class
{
Public:
BOOKARRAY m _ bookarray// book collection
Public:
void AddBook(CBook * book); //Add books
void delete book(int id); //Delete books by number.
void modify book(CBook * book); //amendment
void search book(int id); //Search by number
void search book(char * name); //Search by Title
Invalid search book (floating price); //Search by price
};
void CBook manager::AddBook(CBook * book)
{
This-> m _ book array . push _ back(book);
}
void cbook manager::delete book(int id)
{
book array::iterator it = this-& gt; m _ book array . begin();
And (it! = this-& gt; m_bookarray.end())
{
if((* it)-& gt; m_ID == id)
{
This-> m _ book array . erase(it);
Return;
}
++ it;
}
}
void CBook manager::modify book(CBook * book)
{
int len = this-& gt; m _ book array . size();
if(len & gt; 0)
{
for(int I = 0; I & ltleni++)
{
If (this->; m _ book array[I]-& gt; m _ ID = = book-& gt; m_ID)
{
strcpy(this-& gt; m _ book array[I]-& gt; m_name,book-& gt; m _ name);
This-> m _ book array[I]-& gt; m _ price = book-& gt; m _ price
Return;
}
}
}
}
void cbook manager::search book(int id)
{
int len = this-& gt; m _ book array . size();
if(len & gt; 0)
{
for(int I = 0; I & ltleni++)
{
If (this->; m _ book array[I]-& gt; m_ID == id)
{
This-> m _ book array[I]-& gt; Display ();
Return;
}
}
}
}
void cbook manager::search book(char * name)
{
int len = this-& gt; m _ book array . size();
if(len & gt; 0)
{
for(int I = 0; I & ltleni++)
{
if(strcmp(this-& gt; m _ book array[I]-& gt; m_name,name) == 0)
{
This-> m _ book array[I]-& gt; Display ();
Return;
}
}
}
}
Void CBookManager::SearchBook (floating price)
{
int len = this-& gt; m _ book array . size();
if(len & gt; 0)
{
for(int I = 0; I & ltleni++)
{
If (this->; m _ book array[I]-& gt; M _ price = = price)
{
This-> m _ book array[I]-& gt; Display ();
Return;
}
}
}
}
int main()
{
CBookManager bookmanager
//Add books
Bookmanager.addbook (newcbook (1, "Pig1",52.4 f)););
Librarian. AddBook (new CBook(2, Pig 2, 40.4 f)););
Librarian. AddBook (new CBook(3, Pig 3, 33.4 f)););
Librarian. AddBook (new CBook(4, Pig 4,12.4f));
Librarian. Addbook (newbook (15, Pig 5, 8.4f)););
Librarian. Addbook (newbook (16, Pig 6, 7.4f)););
Librarian. Addbook (newbook (12, Pig 7, 99.4 f)););
Bookmanager.addbook (newcbook (19, Pig 9,100.4f));
int len = bookmanager . m _ book array . size();
printf("//////////////////////////////\ n ");
for(int I = 0; I & ltleni++)
{
book manager . m _ book array[I]-& gt; Display ();
}
printf("//////////////////////////////\ n ");
//Delete the book with book number 15.
Librarian. delete book( 15);
//amendment
CBook book(3, "sheep 1", 50.2f);
Librarian. modify book(& amp; Book);
int len 2 = bookmanager . m _ book array . size();
for(int I = 0; I & ltlen2i++)
{
book manager . m _ book array[I]-& gt; Display ();
}
printf("//////////////////////////////\ n ");
//Find books
Librarian. SearchBook ("sheep1");
getchar();
Returns 0;
}