I saw a lot of similar questions about deleting twice, but what happens when you allocating twice and delete only once? isn't the old version is still exist and how does the program compile?
Don't I have to kind of release the new one too, because according to the d'tor it gets called only once.
For example:
int main()
{
int *ptr = new int;
*ptr=5;
ptr=new int; //again, different memory location
*ptr=25;
delete ptr;
return 0;
}
what with the 5?? it will be a memory leak or something?