Replacing array of objects by array of pointers