used a function to do the char-digit --> int conversion, used copy constructor to fix the iterator problem