Hi there. I am having some trouble trying to figure out how to delete a pointer that is held in a vector.
int main()
{
vector<Test*> iVector1;
vector<Test*> iVector2;
vector<Test*>* pVec1(&iVector1);
vector<Test*>* pVec2(&iVector2);
pVec1->push_back(new Test(11));
pVec1->push_back(new Test(12));
pVec2->push_back(new Test(23));
pVec2->push_back(new Test(24));
//delete iVector1.at(0);
delete iVector1[0];
iVector1.at(0) = new Test(21);
pVec1->at(1) = new Test(22);
}
neither of the delete lines i have tried work. Both result in a link1120 error.
The purpose of this program is to test various vector functionality, so i know what to do when i apply it to a larger program i am working on. that is why there are both Vectors and Vector pointers.
Any help is much appriciated. (let me know if you need more information)