+ 4

How use new and delete operators in c++?

25th Apr 2017, 3:33 AM
Sahil Sharma
Sahil Sharma - avatar
2 Answers
+ 3
new and delete operators are used with the pointers When you create a pointer : - the pointer can point to an existing variable : *p = &var - or it can point to a new variable : *p = new int; In the second example, we create an int variable and we point to it. When you create variables using new, you must erase it from the memory by using delete when you don't need it anymore.
25th Apr 2017, 3:45 AM
Toky R.
Toky R. - avatar
+ 1
new and delete operators are used with the pointers When you create a pointer : - the pointer can point to an existing variable : *p = &var - or it can point to a new variable : *p = new int; In the second example, we create an int variable and we point to it. When you create variables using new, you must erase it from the memory by using delete when you don't need it anymore.
16th Feb 2018, 1:03 PM
Васильев Михаил
Васильев Михаил - avatar