Lesson 20 of 24
Pointers, new/delete, Smart Pointers
11 min 35 XP
new heap memory നൽകുന്നു, delete അത് സ്വതന്ത്രമാക്കുന്നു; delete മറന്നാൽ memory leak. Modern C++ memory സ്വയം സ്വതന്ത്രമാക്കുന്ന unique_ptr, shared_ptr എന്നിവ ഉപയോഗിക്കുന്നു.
Example: edit me and press Run
Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.new[]-നൊപ്പം delete[], new-നൊപ്പം delete; ഇവ കലർത്തുന്നത് undefined behaviour ആണ്. Smart pointers ഈ തെറ്റുകൾ പൂർണ്ണമായും ഒഴിവാക്കുന്നു.