Updated program to use class templates