Returning an instance of a class.

So i have a weird problem that isnt exactly an error, its just something im not understanding. i have the following peice of code and the functions it calls. What happens is when the indicated line is run, i get an output telling me the 2nd constructor has been called, which is fine, then i get another line telling me the coppy constructor has been called. Thats no so fine, so i worked out its because im returning a pointer to an instance of the class. Im not sure why it needs to call the copy constructor, i had thought that a pointer was simply a storage unit for a memory address of the thing it points to, in this case an instance of DNA.

So what it now comes down to, is how do i return an instance of a class, without having to create it twice. For instance i return a pointer to a class and it calls the copy constructor, i therefor assume that its creating it again. I return a reference, then the instance of the class goes out of scope because the function ends, i return an actual instance of the class and im pretty sure that creates it twice, because it calls the copy constructor.

The reason i dont want it being created twice is that its obv a drain on resources and i have no way to un-allocate the memory after the function has ended. Is that even a problem? i would imagine so because i havnt called a destructor.

So yea, im slighlty confused, help would be muchly appriciated.

EDIT:: I also forgot to mention that i have written a custom copy constructor and that being another reason why i dont want it being called.

>DNA Mate = *(testDNA.CrossoverMutate(testDNA2));
The copy constructor will be called here to initialize Mate with the dereferenced pointer. If you don't want that happening, make Mate a pointer as well:

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...