What you might want (though not sure from the question yet), is an array of pointers to DNA objects.
What you are declaring is "just" an array of DNA objects; and you can't set an object to null, as Pete Becker's answer explains very well.
The following code would work:
// notice how we use +1 here to have place for the NULL element at the end
DNA* newDNA[] = new DNA*[allRightSequences.size()+1];
newDNA [allRightSequences.size()] = NULL;
For each element of the array, you'd however also have to create a DNA object via new DNA...
then...
Note that if you use a compiler supporting C++11, use nullptr
instead of NULL
.
And if you want to avoid the hassle with pointers completely, you could use a construct like std::optional
in case you use C++17 or boost::optional
for earlier versions, as described in this answer to another question, as mentioned by Baum mit Augen above.
Also, the good question is what you really need that zero pointer at the end - if it's just for determining the last element when iterating over the array, then you might be better off using an std::vector<DNS>
or a similar collection type instead...