Memory leak then releasing memory

Hello, maybe someone could to say example of memory leak where is releasing memory before removing last reference? Or other simply memory leaking example with memory releasing. Thanks for everyone.
Do you mean dangling pointers?
Releasing memory before last usage:
1
2
3
int* pointer = new int;
delete pointer;
*pointer = 4;
Pointing to stack-allocated memory after it is no longer in scope:
1
2
3
4
5
6
int *pointer = 0;
{
    int x = 7;
    pointer = &x;
}
(*pointer) -= 3;


@Moschops:
delete &(*(new int) = 4);
Just for fun...not actually trying to say anything.
Last edited on
Hey, I'm all about the fun.

All. About. It.
Topic archived. No new replies allowed.