I don't understand the way this is working. Im tring to create an array of strings from a list of strings. I count the number of strings in the list and then want to create an array of these strings. I was doing some testing and came up with this code:
string *newOrder;
int numNodes;
numNodes = alphaTree.numNodes();
newOrder = new string [numNodes];
newOrder[0] = "This is";
newOrder[1] = "a test";
newOrder[2] = "To see";
newOrder[3] = "If this";
newOrder[4] = "will work";
The results are that newOrder acts like it is a single string array having the vaule "This is". What am I doing wrong?
std::vector. All use ofnew,new[],delete,delete[],~T(),malloc, orfreeshould be avoided except in a class that does nothing else but call them (for example, when writing a custom smart pointer or typesafe union).