Hello, what does this line of code (in bold) do exactly:
Does it create a new node structure at that point, and point at it with "root"? Or is it only saying to point at any new node structure in the future, which is explicitly created?Code:struct node { int x; node *next; }; int main() { node *root; // This won't change, or we would lose the list in memory node *conductor; // This will point to each node as it traverses the list root = new node; // Sets it to actually point to something
And I'm assuming, since its the "new" keyword, that this new object/structure/or-whatever-you-want-to-call-it is created in the "heap" section of memory, correct? Why, then, is there no need for the delete keyword to delete the "root" variable?



LinkBack URL
About LinkBacks




