0

I am deleting a pointer using "delete" in C++.
That pointer is holding the address which is used by OS like 0x00000210.
What will happens?

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by CoolGamer48
0

I am deleting a pointer using "delete" in C++.
That pointer is holding the address which is used by OS like 0x00000210.
What will happens?

You got the problem all wrong. First you can't delete something used by the OS.
Your process has it's own adress space, so adress 0x00000210 is not the fizical memory adress, is just a virutal adress used by your own process, so you can't reference memory locations outside your own adress space.

Most likely if u do something like

int x = 0x00000210;
	void *p = (void*)x;
	
	delete p;

you will end up with an access violation and your program will terminate

0

Do you mean manually deleting data at an address you chose? Or are you just asking what delete does?

int* x;//declare a pointer to an it
x = new int;//create an int somewhere in memory and store its address in x
*x;//access the actual int stored at the location that x has
delete x;//delete the int stored at the location that x has
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.