changed ex7_31.cpp to ex7_31.h

1. remove redundancy of include.
2. remove `class X`
fixed bugs