### Is there any thing wrong in this vector code ?

I am tying to delete those customer whose age is 15
So entered the data as 12,13,14,15,16,15,17,15,18,15.
Size is 10 and capacity is 10.
After deleting the customer whose age is 15, still the size is 10 and capacity is 10.
The size should be 6.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051`` ``````#include #include #include using namespace std; class customer { int Age; public: customer(int a) : Age(a){ cout << "Customer created for Age:" << a << endl; } ~customer() { cout << "Destroyed for age " << Age << endl; } int getAge() const { return Age; } }; template struct DeleteCust { private: T value; public: DeleteCust(T a) : value(a) {} void operator()(const customer* obj) const { if(value == obj->getAge()) delete obj; } }; int main() { std::vector vect; vect.reserve(10); for( int i=0; i<10; i++) { int Age; cout << "Enter Age:" ; cin >> Age; vect.push_back(new customer(Age)); } cout << "size is" << vect.size() << endl; cout << "Capacity is" << vect.capacity() << endl; int Age; cout << "Enter the age to delete:"; cin >> Age; for_each(vect.begin(),vect.end(),DeleteCust(Age)); vect.erase(remove(vect.begin(),vect.end(),static_cast(NULL)),vect.end()); cout << "size is" << vect.size() << endl; cout << "Capacity is" << vect.capacity() << endl; //vect.push_back(new customer(Age)); //cout << "size is" << vect.size() << endl; //cout << "Capacity is" << vect.capacity() << endl; return 0; }``````
 ``1234`` ``````Foo* foo = new Foo; Foo* bar = foo; delete bar; assert( foo == nullptr ); // failure ``````