cpp newbie here
If I initiate a two pointers, like
int* a = new int(1);
int* b = new int(2);
and I want to give the pointer a
a new value, shoud I delete its current value before?
In other words, what is more correct, doing
int* a = new int(1);
int* b = new int(2);
a = b;
or
int* a = new int(1);
int* b = new int(2);
delete a;
a = b;
I know I shoud use smart pointers, or NOT use them at all as a begginer, my question is more about the memory management in theory. Thanks in advance!