When using memcopy
does it just copy the objects in the array or does it copy the memory address of the object and place it in the new array?
If not is there a way to copy the address of objects in array?
Below are the array definitions:
private:
Node<T>* m_data;
long m_size;
bool m_asc;
Node<T>* m_curr;
I have a method that inserts into m_data
, but sometimes m_data
needs to be expanded and thus copied over to a temporary array. The problem with that is that in the Node class definition (shown below) connects between successive elements in an array by saving their pointer. If I copy the elements of one list to another it changes their memory address, which results in changes using the pointers not being reflected in the elements of the array. Is there a way to resolve this?
Node<T>* m_next; // pointer to successor element.
Node<T>* m_prev; // pointer to predecessor element.