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
Post a Comment