A C++ exercise