add delete function to lab2.cpp