I'm a Java programer lost in C++ and pointers :D
I have an array of pointers to Bucket-Objects
Bucket<E>* index = new Bucket<E>[2];
I initialize it like this:
index[0] points to Bucket1
index[1] points to Bucket2
And then I want to double the size of the array and link the additional entries like this:
index[0] points to Bucket1
index[1] points to Bucket2
index[2] points to Bucket1
index[3] points to Bucket2
I have this code so far, which generates copies of the Bucket-Objects and I don't want that!
for (size_t i = 0; i < newSize; ++i)
{
if (i < oldIndexSize)
newIndex[i] = index[i];
else
newIndex[i] = index[i - oldIndexSize];
}
Bucket<E>** index = new (Bucket<E> *)[2];Bucket<E>**?Bucket<E>** index = new Bucket<E>*[2];Bucket<E>**) confusing, you may want to use some intermediatetypedeffor better code clarity, e.g.typedef Bucket<E>* BucketPtr;, and then allocate withBucketPtr* index = new BucketPtr[2];.