I would like to create a function similar to the Array.Copy
of C # in C ++.
This function has the prototype like this:
public static void Copy(
Array sourceArray,
int sourceIndex,
Array destinationArray,
int destinationIndex,
int length
);
And I would like to do a function that would do the same function in C ++.
I tried to do using for
, but I could not make it work with destinationIndex
.
My code:
template <T> void Buffer <T> ::copy(T * src, int indexSrc, T * dst, int indexDst, int elements) {
for (int srcAux = indexSrc, dstAux = indexDst, int aux = 0; aux != elements; srcAux++, dstAux++, aux++) {
dst[indexDst] = src[srcAux];
}
}