But now I'm starting to overload the operators like +, * to implement all the ops with matrices. When I use a statement like A = B + C (all these variables are matrices), the values from B and C are summed and put on a new temp matrix which is returned from the overloaded operator function. And it happens that the default copy constructor copies the POINTER _pMatrix, making two different and independent pointers point to the same resource. Now, after the temp matrix with the summed values is returned, it runs out of scope and its destructor (which deallocates the resource) is called. And then the A matrix contains a _pMatrix member pointing to a deleted resource!!!
All I could think of was to implement a new copy constructor that would copy all non-pointer members of the source class to the destination class, allocate memory for the destination class' _pMatrix member and copy the entire contents from the source _pMatrix. Then, I have two different pointers pointing to two different resources, but both resources are identical.
If I'm using a 4x4 matrix of double, imagine the memory it was going to use!!!! It would take a lot of resources from the heap and cycles from the processor to do all this!!!!
Isn't there any other viable solution to copy the source object and its allocated resource to the destination???