Consider I have the function:
int &create_ptr(){
int *x = new int;
*x =5;
return *x;
}
int main(){
int y = create_ptr();
}
Will this cause a memory leak or is there somehow to delete it? Sorry if it's a basic question, this has just been bugging me and I couldn't really find the answer.
Thank you everyone, makes sense now!