Memory from heap
-
Hi!! A program allocated memory from heap using new, something like this int * a = new int[20]; i.e program created ten int objects using heap. Later in the program suppose we only require first ten of these while other are found useless, then how can we delete the objects from int[10] to int[19]
-
Hi!! A program allocated memory from heap using new, something like this int * a = new int[20]; i.e program created ten int objects using heap. Later in the program suppose we only require first ten of these while other are found useless, then how can we delete the objects from int[10] to int[19]
I dunno if you can delete the last 10 only, but the safest bet is to make a new int[10] and copy the 10 you want into it. Easier, just use std::vector instead. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Anonymous wrote: OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window. I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
-
I dunno if you can delete the last 10 only, but the safest bet is to make a new int[10] and copy the 10 you want into it. Easier, just use std::vector instead. Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Anonymous wrote: OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window. I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
Hi.. I think it's not possible using new , delete use
malloc
,realloc
,free
stuff to make it (includestdlib.h
andmalloc.h
)or use STL or make a linked list instead of using arrays -
Hi.. I think it's not possible using new , delete use
malloc
,realloc
,free
stuff to make it (includestdlib.h
andmalloc.h
)or use STL or make a linked list instead of using arraysA linked list will have completely different behaviour to a vector/self rolled array wrapper. You need to be careful that this is the sort of behaviour you want ( fast insert, slow lookup ) Christian NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma Anonymous wrote: OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window. I think you are a good candidate for Visual Basic. - Nemanja Trifunovic