How do I implement the following class?
<p>I am writing a personal library management project for an exam, using C++. The library consists of sets (arrays, vector or lists, I'm still deciding) of <code>Book</code>, <code>Film</code> and <code>Album</code> objects (with the same base class <code>Media</code>) and a set of <code>Friend</code> objects. The user can Add and Remove entries in these sets.
These sets save (and load) their data in separate text files, with the structure I reported here:</p>

<p><a href="http://stackoverflow.com/questions/8444052/how-to-parse-the-following-text-file-into-class">How to parse the following text file into class?</a></p>

<p>I must implement a class <code>Loan</code>, with a field referring to a <code>Media</code> and one referring to a <code>Friend</code> stored in the respective sets. The operations that must be possible on the <code>Loan</code> objects are addition, removal and visualization. Moreover the set of <code>Loans</code> must be saved to a text file (the structure is not provided but should follow the one for the other types) and loaded when the program starts.</p>

<p>My question is how should I do this. I mean the fields <code>friend</code> and <code>media</code> should be references? Pointers? copies of the objects? How do I ensure that the Loan will point to the same objects after the program restarts, maybe after a removal operation? How would I store the <code>Loan</code> in a text file?</p>
