I am using shallow copy to copy one object to another object and when main() goes out of scope destructors are called and error ": double free or corruption (fasttop):" is thrown which is perfectly fine as I am using shallow copy. Now when I am creating another object between the two copies, it doesn't throws any error, which is bugging me.
int main(int argc, char *argv[])
{
int n =5;
vector vec(n);
vector vec1(vec);
cout<<vec<<endl;
cout<<vec1<<endl;
return 0;
}
which gives output Which is expected as I am using shallow copy Now when I am adding one more object in between, then no error is thrown
int main(int argc, char *argv[])
{
int n =5;
vector vec(n);
vector vec2(n);
vector vec1(vec);
cout<<vec<<endl;
cout<<vec1<<endl;
return 0;
}