Given the following Array class, how should we implement the destructor so that it causes no errors and avoids memory le

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Given the following Array class, how should we implement the destructor so that it causes no errors and avoids memory le

Post by answerhappygod »

Given The Following Array Class How Should We Implement The Destructor So That It Causes No Errors And Avoids Memory Le 1
Given The Following Array Class How Should We Implement The Destructor So That It Causes No Errors And Avoids Memory Le 1 (38.24 KiB) Viewed 23 times
choices:
Given The Following Array Class How Should We Implement The Destructor So That It Causes No Errors And Avoids Memory Le 2
Given The Following Array Class How Should We Implement The Destructor So That It Causes No Errors And Avoids Memory Le 2 (34.61 KiB) Viewed 23 times
Given the following Array class, how should we implement the destructor so that it causes no errors and avoids memory leaks? #include <string> #define MAX 256 using namespace std; Class Student public: Student(const string& n = "000000000",const string& s = "Hey you!"); private: string number; string name; undefined class Array { public: Array():size(){elements = new Student [MAX); } Array(); void add(const string& name, const string& num); int get(int index); int getSize(); private: int size; Student* elements;
Array(){ delete [] elements; -Array { for (int i = 0; i < size; ++i) { delete elements; } delete [] elements; undefined Array ( 0 Array() { for (int i = 0; i < MAX; ++i) { delete elements[1]; } delete [] elements; None of these.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply