added cpp version
some improvements (very informative, captain unobvious!)