chpaters 1-2 revision cpp code