I\'m trying to delete everything from a std::vector by using the following code
vector.erase( vector.begin(), vector.end() );
If your vector look like this std::vector you have to explicitly release memory ,Or if your vector look like : std::vector , constructor will be called by vector.Please execute example given below , and understand the difference :
class MyClass
{
public:
MyClass()
{
cout<<"MyClass"< vecType_ptr;
typedef std::vector vecType_obj;
vecType_ptr myVec_ptr;
vecType_obj myVec_obj;
MyClass obj;
for(int i=0;i<5;i++)
{
MyClass *ptr=new MyClass();
myVec_ptr.push_back(ptr);
myVec_obj.push_back(obj);
}
cout<<"\n\n---------------------If pointer stored---------------------"<