As the title suggests I am wanting to recreate an array which will have a different size than the original one.
My original array is created when a class is initiated and it is in the private member of the class. The array is called Node* arr[10]. It is set up with the size of ten originally and once the application requires more space for the length I wish to create a a new array using memcpy which will be the same as original arr but the only difference would be its max size.
Below is the code I have come up with however I am met with an error.
//Part Of Class
private:
Node* arr[10];
//Part Of Method
size_t newSize = size * 2;
Node** newArr = new Node*[newSize];
memcpy(newArr, arr, size * sizeof(Node*));
maxSize = newSize;
delete[] arr;
arr = newArr;
The error is shown at the last line, arr = newArr, and it states that it cannot convert from Node** to Node*[10]. Why exactly is this? Is it because Arr is initiated when the class first is?
Hovering over newArr shows Node** while hovering arr shows Node* Map::arr[10]. Could someone please explain my options with this as I am wanting to stick with arrays and I do not want to change over to vectors. I understand the issue is with them not being classed as the same type however if I remove the second asterisk on the newArr = new Node* ect line it says it cannot convert too.
Thank you for taking the type to read my issue and I hope the question is in the correct format, Regards