Write and test a class which will hold information on a book. The information that the class must store is:
Author (a string)
Title (a string)
There should be methods to get these values. Also:
• There should be an overloaded output (“<<”) operator which outputs the data (i.e. author and title) as a single string (with an appropriate character such as “:” separating the two elements).
• There should be a “write to file” method (which will take a file stream object to write to as a parameter) – although at this stage you could use the output operator (above), you will avoid problems in the later stages of the assignment if you adopt this approach (hence it is mandatory that you have this method). Life will be easier if you write the author and title on separate lines.
• There should be a matching “read from file” method (which will again take a file stream object to read from as a parameter)
• You will need at least three constructors (a default constructor, a parameterised constructor and a copy constructor).
• Although a destructor will do nothing, it might be worth adding one as it will help you debug later stages of the assignment.
• You need to write a main program which is a test harness which will test fully the operation of this code for this class. Testing that the copy constructor is called correctly will require a little thought – but not much if you remember that it is called when a copy is made in a pass-by-value function call.
• There should be three source files, the class header file, the class body file and the main program/test harness.
Re: help me,please
Do you think anyone will read this all?
|All times are GMT +5.5. The time now is 20:58.|