+ 1

May you explain me new and delete in the code, please?

Dynamic Memory https://code.sololearn.com/ckV36vAWidzA/?ref=app

6th Dec 2020, 1:23 PM
lifeismyschool
6 Réponses
+ 5
lifeismyschool You want to know the meaning of cout or whole code?
6th Dec 2020, 1:56 PM
Piyush
Piyush - avatar
+ 2
lifeismyschool int main() { int *p = new int; // request memory *p = 5; // store value delete p; // free up the memory // now p is a dangling pointer p = new int; // reuse for a new address *p=20; cout<<&p<<endl; // address of p cout<<*&p<<endl; // value (a pointer) at address p cout<<p<<endl; // value of p (an address) cout<<**&p<<endl; // value (an int) at a ptr value at the address of p cout<<*p<<endl; // value at p pointer return 0; }
6th Dec 2020, 2:49 PM
Flash
+ 1
Please post your question just once. It won't get more answers when it exists a couple of times. Please delete those duplicate questions. Thank you.
6th Dec 2020, 2:19 PM
Julian
Julian - avatar
0
lifeismyschool Be more specific when asking questions or let life teach you!
6th Dec 2020, 5:05 PM
Crash
Crash - avatar
0
Piyush I want to know whole code with cout descriptions.
6th Dec 2020, 5:11 PM
lifeismyschool
0
Friends in fact I want to know about using new, NULL, delete, pointer together.
6th Dec 2020, 5:40 PM
lifeismyschool