c++ implemention