C++.how to write a selection sort to sort it.
read_book_data()
This member function takes one parameter, a string that containsthe name of a file. This string parameter can be a C++ string or aC string (your choice). The function returns nothing.
This constructor should do the following:
Declare and open an input file stream variable using the filename string passed in as a parameter.
Check to make sure the file was opened successfully. If not,print an error message and exit the program.
Read the file into your book_store object using theifstream::read() member function for binary input.
Close the file stream variable.
Sort the book objects in the array in ascending order by ISBNnumber using a sorting algorithm of your choice. Note that theISBNs are C strings, which means that you will not be able tocompare them using the standard relational operators. The ISBN isalso private data of the book class, so code in the book_storeclass will need to call get_isbn() for book object rather thanaccessing the object's ISBN directly.
Note that the code described above will read data intoall of the book data members. That includes boththe array of 30 book objects, and the number of array elementsfilled with valid data. No further initialization of the datamembers will be needed
void book_store::read_book_data(string data)
{
ifstream inFile;
inFile.open(data, ios::binary);
if( inFile.fail() )
{
cout << \"input file did not open\";
exit(-1);
}
inFile.read((char*)this, sizeof(book_store));
inFile.close();
}
C++.how to write a selection sort to sort it.