using c++ language implement design patter