Hello, and welcome to the 41st tutorial in the c++ programming series. And in this part, we're gonna be looking at the Delete operator. The delete operator allows memory to be freed up data is not being used anymore by a pointer because you have to allocate memory dynamically to a pointer. So if you're not no longer use the neck, it's recommended to free it up so are the applications or other parts of your application can use that memory. Otherwise, you can get memory leaks, your application start using too much memory, you can get crashes, sort of stuff that you obviously don't want. Let's go ahead and open up our project.
We're going to do this create a really simple pointer and then show you how to delete it. So we're going to put a pointer call it P. So some memory we can assign a value. Seven. Good to see that's trippy Line everyone this with the valley center. But to actually just delete your pointer, it's simple you just use a keyword delete, specify the name a point, a double asterisk, anything like that. So pay semicolon, then you assign the value you know to pay for p equal No.
And now you just do STD. C Yeah, this is unnecessary, but this is to show you see the final column and write and run. Your bill succeeded and it had basically crashed here because we're trying to access memory which no longer exists, but if we just comment this line and run it, it runs fine because memory has been deleted successfully. And it was a okay I won't comment this on back and I will leave it commented out. Well that's it for this tutorial. In the next part of this series, we're going to be looking at strux piano questions.
Feel free to message us at support at solar systems calm Okay, the email will be in the description you can comment in this video or just directly message via YouTube or the recording for all the required links will also sorry, review that all the required link for source code will also be in the description and as usual, thanks for watching and I hope you have a nice day.