cpp implemantation of Candy