I have created a function which returns a matrix object of a class called Matrix by processing another matrix object. What it does is that it gets the passed matrix object, creates a new matrix object and points at it using a pointer, copies all the data from source matrix object to destination new matrix object, and returns the new matrix object.
Now I am confused here about which pointer to set as null and then delete. I am creating two matrix objects here, but the function is returning one. Do I need to delete the passed matrix object inside the function after it has been copied to the other new matrix object?