cpp rewrite