T *temp_array = new T[cols]; for ( int i=0; i< cols; i++) { temp_array[i] = push_vector[i]; } // temp_array has the values. T *temp_value[rows+1]; for ( int i=0; i< rows; i++) { temp_value[i] = values[i]; } // temp_value has all the pointers that was in values. temp_value[rows] = temp_array; // completed. for ( int i=0; i< cols ; i++) { delete values[i]; } // values deleted. all the dynamic memory deleted. for ( int i=0; i< rows+1; i++) { values[i] = temp_value[i]; } // temp_values added to values.