Vote count:
0
Below is the code for constructor and destructor. Destructor successfully destructs the array created by option 1. What if we have multiple array as in option 2. Will the same destructor coding is enough to delete or some changing in the code is required.
Mystack::Mystack()
{
capacity = 3;
top[3] = { -1 };
input[] = new int[capacity]; //option 1
input[3] = new int[capacity];// option 2
}
Mystack::~Mystack()
{
delete[]input;// Works for option 1. Should it be same for option 2??
}
asked 1 min ago
Destructor for deleting arrays
Aucun commentaire:
Enregistrer un commentaire