Hi,
How can i delete a particular element using delete operator?
Thanks
Warning! O_O
Delete does not really delete!
Delete frees dynamically-requested memory that the C++ program obtained from the OS at run-time.
Delete does NOT actually delete anything! Do not use it freely, unless you really want to screw up your program or cause your OS to flag an error to whatever program attempted to tell the OS to unallocate memory that never belonged to the provoking application to begin with @_@.
>How can i delete a particular element using delete operator?
Can you be more specific? A vague question produces vague answers, or completely off-the-wall answers as exhibited by the previous reply.
delete Operator (C++):
http://msdn.microsoft.com/en-us/library/h6227113(VS.80).aspx
Dynamic Memory:
http://www.cplusplus.com/doc/tutorial/dynamic.html
Hi,
I am getting the following error :
test.o(11488) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
test.o(11488) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
test.o(11488) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
test.o(11488) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
terminate called recursively
Abort trap
I am using finite recursion to build the nodes of binary tree. So i believe the C++ program should take care of the storage of nodes. I also think that it will store the nodes of the binary tree in a heap. So, i was thinking of trying to free some space during recursion using delete operator.
I am trying to free the memory corresponding to the second element of the 2 dimensional array.
Please help
Thanks
why are you using malloc() in a c++ program -- malloc() doesn't know how to allocate c++ objects? Use the new operator instead.
And you can not use the delete operator to free memory that was allocated by malloc(). delete only works with new.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.