Hi,
I need to write implement exceptions, that prints error message to the screen, that appropriate to the LibraryItem kind, Book or ReservedBook.
what changes should i do to the borrowTitle function ?
my function didn`t refer to differences between Book and ReservedBook and Jorunal.
note: couts with ******** are the expected outputs.
"Exceptions" shouldn't print anything on the screen. Exceptions should break your program, go to the closest catch() and carry some information about why the exception occurred. That might be an error message that you may decide to print on your screen, but the exception itself doesn't print anything.
if i want to borrowTitle that already borrowed, the function have to throw a message says that the title is already borrowed, bout it need to tell if it a book, reservedbook or journal. (like what in the couts with *******).
You can do that by passing the relevant parameters (the catalogid or whatever) to the exception's constructor, which can then construct a string out of it (which you need to store in the class). Use c_str() to return the string in what().
Note: you might want to inherit from std::runtime_error: http://www.cplusplus.com/reference/std/stdexcept/runtime_error/