Resource-efficient programming (INF205) lab u39: 29th September 2022

1. Module feedback and recommendations

Many thanks for providing your constructive criticism of the module in order to keep it on track. The same ideas as in no. 1 from lab u37 continue to apply this week.

2. Class with private members

In the lecture, we took "struct BookIndex" and converted it into a class whose properties were all private.

Do something similar with the outcome from last week's exercise no. 3 (struct for spheres, applied to counting the overlaps between spheres). Turn the structure into a class with a more high-level object-oriented design.

If you did not work on week 38 problem no. 3, use the published solution as a basis.

3. Inheritance and virtual methods

The "inheritance" example code defines a class LiteratureIndex at the top of a class hierarchy; another class, JournalArticleIndex, is defined to be a subclass of LiteratureIndex: class JournalArticleIndex: public LiteratureIndex{ … };

The code also has a class BookIndex (based on struct BookIndex, see above). It is now the task to turn this into a subclass (derived class) of LiteratureIndex as well.

  1. Look at the code, discuss it, and ask questions in the tutorial session until you are confident that you understand everything.
  2. Now continue developing the code such that BookIndex becomes a subclass (derived class) of LiteratureIndex.

Remark

Best submit your code as is, for example in a ZIP file, not as text pasted into a PDF even if that would look more polished. That way it will be easier to provide relevant feedback and detect bugs if there are any.