help me,please

Discussion in 'C' started by slavad, Nov 15, 2007.

  1. slavad

    slavad New Member

    Joined:
    Nov 15, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. aVague

    aVague New Member

    Joined:
    May 2, 2007
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    forex
    Do you think anyone will read this all?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice