Solution to the Fish problem in C++