What code should we put in the space labeled "\\insert code here" to avoid memory leaks, compiler and runtime errors? cl
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What code should we put in the space labeled "\\insert code here" to avoid memory leaks, compiler and runtime errors? cl
What code should we put in the space labeled "\\insert code here" to avoid memory leaks, compiler and runtime errors? class Student public: Student (const string& n ="000000000",const string& s ="Hey you!"); public: string number; string name; int main() { vector<Student*** students = new vector<Student*>; students->push_back(new Student("123", "Alice")); students->push_back(new Student("456", "Bob")); students->push_back(new Student("789", "Charlie")); //insert code here return a; Nothing. When the vector goes out of scope it will delete itself and all data. for (int i -e; 1 < 3; +i){ delete (*students); delete students; a O delete students; for (int i = 0; i < 3; ++i) { delete ("students)[1];
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!