What happens with the element-value of top_node after pop-function, C++ -


i create pop()-function:

void stack::pop(){ assert(!empty()); element* p=top_node; top_node = top_node -> next; delete p; } 

the top_node , p pointer pointing uppermost element in stack. after top_node-pointer points next element, p deleted. p pointer, happens whole element(int i, element* e). have clear separately? or more precisely, every pop , push function belongs clean function?

thank you!

this happens if pointer p points user-defined type

class x{     x() {};     ~x(){}; };  x* p = new x; // calls default constructor delete p; // calls destructor 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -