Exercises in this lecture   previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Go to the notes, in which this exercise belongs -- Keyboard shortcut: 'u'   Alphabetic index   Course home      

Exercise 2.5
Ways of returning results from the div function


This exercise works in the context of the divide program from the slide about constant references.

Program the struct ldiv_t and the function div yourself, instead of using the definitions from the std namespace.

Run the program with your own versions of ldiv_t and div.

Experiment with returning a reference ldiv_t& from div. (See page 282-283 in The C++ Programming Language).

And similarly, experiment with returning a const reference const ldiv_t& from the div.


Solution