The code below is a toy example of something I'm trying to do that might be misguided. I believe this is leaking memory since I'm using new but not deleting. Is that correct, and if so, is there any way to delete the leaking stuff within the main method? Or is it inaccessible at that point?
#include <iostream>
using namespace std;
int* f(){
int* x = new int;
*x = 4;
return x;
};
int main(){
cout << *f();
return 0;
}