Exercises in this lecture  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 5.11
Interval indexer


The Interval type represents an oriented interval [from - to]. We use the Interval example to illustrate the overloading of operators. If you have not already done so, read about the idea behind the struct Interval in the course teaching material.

In the client of struct Interval we use an indexer to access elements of the interval. Where, precisely, is the indexer used?

Add the indexer to the struct Interval (getter only) which accesses the i'th element of the interval.

Be careful to take the orientation of the interval into account.

Would it make sense to program a setter of this indexer?


The solution to this exercise has not yet been released