add doc learning cpp by refactoring