Essentially, if I create multiple instances of a new class, do I need to call the destructor for each instance, or will invoking it once destroy each instance(I apologize if I'm using vague/wrong terms, constructors/destructors are concepts I don't fully grasp yet).
To be more specific, this is some code I'm working with(I'll have to apologize again if the style is bad, I had an idea for a school problem and wanted to get the code down quickly).
while(read >> f >> l >> t >> s >> sta >> acct >> bal)
{
cout << "test" << endl;
ptr[i] = new account(f,l,t,s,sta,acct,bal);
ptr[i]->printcontents();
cout << "test" << endl;
i++;
cout << i << endl;
}
So for the sake of the question, assume this'll loop three times. Will I only have to invoke the destructor of "account" once to destroy all three instances of new account, or will one call leave the other two? Is this even a good practice?
Edit: I noticed some of my post got cut off, so I added the last few lines, but people have already addressed that issue. The reason I'm user pointers is purely because the assignment dictates I do so; quite frankly I don't see the point in using them at this moment, but I assume somewhere down the line they become useful. I should also add that dynamic memory allocation is also supposed to be used in the assignment.