If I have
Class *a1 = new Class();
Class *b1 = a1;
delete b1;
delete a1; //this will give a double free or corruption message;
if I delete pointer b, it's the same as deleting pointer a right? Since the two are pointing at the same instance of Class. So, how can I copy the instance of a1 to b1 so that when I delete b1, a1 is NOT deleted.
Class *a1 = new Class();
Class *b1 = a1;
//how do I duplicate the instance a1 is pointing
//so that when I delete b1, a1 still exists.
delete b1;
delete a1; //this is still valid
Thanks.