Memory Allocation question

Hi,

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;

int main()
{
	int *p;
	p = new int;
	cout << p<<endl;
	p = new int;
	cout << p<<endl;
}


Output:
1
2
0x94b0008
0x94b0018


What happens to the first allocated memory block?
Thanks
You lost it. It's still there, but there's no way of using or freeing it. It's a memory leak.
Thanks ... i feared that.
An additional note: without deleting p, both uses of new are creating memory leaks. See http://www.cplusplus.com/reference/std/new/operator%20delete/
Topic archived. No new replies allowed.