KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am totally confused with regards to deleting things in C++. If I declare an array of objects and if I use the clear() member function. Can I be sure that the memory was released? For example : tempObject obj1; tempObject obj2; vector<tempObject> tempVector; tempVector.pushback(obj1); tempVector.pushback(obj2); Can I safely call clear to free up all the memory? Or do I need to iterate through to delete one by one? tempVector.clear(); If this scenario is changed to a pointer of objects, will the answer be the same as above? vector<tempObject> *tempVector; //push objects.... tempVector->clear();
Tags (comma-separated)
Save Edits
Cancel