   deleting only a memory block from an array of class in C++
  After creating a array from a class with calloc, I would like to delete only a block of that array like:delete(TheClass[n]);Unfortunatly no delete() nor free() is working !I wonder if somehow it's possible to do it.And auxiliary, how can I move or copy a memoryblock from that same array like:memmove(TheClass[n], TheClass[n+1], sizeof(TheClass));Pretty Thanks. That could help me to continue my loved work.   
  If you're using classes, you're not using C and you shouldn't be messing with malloc, free, or related functions.If you must mess with memory manually, use new and delete. Since you're using C++, you have nifty functions like copy, swap, sort, and all manner of other helpful functions defined in the headers 'functional', 'algorithm', and 'iterator'In C++, though, you don't have to mess with memory manually and you should instead use the included classes such as vector, list, set, and map (each one defined in a header of the same name as the class).   ;  Consider instead using std::vector. Then you can just use the erase() member function. Don't use memmove() to copy class types unless they're POD, instead try std::copy().   ;  Try using realloc.  It may do what you're looking for.  Also, beware mixing malloc/realloc/calloc/free with classes.  They don't call the constructors and destructors like new and delete.   ;Quote:Original post by Anonymous PosterTry using realloc.  It may do what you're looking for.No it won't. CM   ;  I've tried to look after the headers "fonctional.h", "algorithm.h" and "Iterator.h", but beside a file "algorthm.???" in the include folder no one was present..using vc6..Though i observed the class's constructors wasn't called, i arranged that by creating a class without constructor, but insteed, an initialisation fonction called after the memory allocation.It would have been kool using realloc, but as McCloud wrote, it doesn't work like i want...'Cause I'm not very comfortable using std::vector, i prefer to investigate in "copy", "swap" and "sort" defined in files i still can't find ! some help ?SiCrane i guess, you mean the same as Extrarius, but concerning "vector list set map", where can i find a good documentation, tutorial like, that puts you directly in the situation, without a whole of BlaBla...?And beside, what's a POD ?!?   ;Quote:Original post by jinuuchukuuI've tried to look after the headers "fonctional.h", "algorithm.h" and "Iterator.h", but beside a file "algorthm.???" in the include folder no one was present..using vc6..It's without the .h at the end. Just <functional>, <algorithm>, etc...Quote:Though i observed the class's constructors wasn't called, i arranged that by creating a class without constructor, but insteed, an initialisation fonction called after the memory allocation.As far as I know, malloc() and friends don't call constructors. operator new does, though.Quote:'Cause I'm not very comfortable using std::vector, i prefer to investigate in "copy", "swap" and "sort" defined in files i still can't find ! some help ?Why are you not comfortable with std::vector?Quote:where can i find a good documentation, tutorial like, that puts you directly in the situation, without a whole of BlaBla...?I've always liked the SGI STL reference, although there is so-called "blabla". You could always look at MSDN.Quote:And beside, what's a POD ?!?Plain Old Data(type)jfl.   ;  For what you are doing, and if you don't want to use the STL (std::vector, std::list, etc), you want to use a linked list: http://richardbowles.tripod.com/cpp/linklist/linklist.htm.  If you don't know what a linked list is or how to use one, then you should most definitely try that approach just for learning's sake.  It's important to know how dynamic data structures work.  If you already know what one is or want to experiment with the STL, you should be using the STL list template: http://www.msoe.edu/eecs/ce/courseinfo/stl/list.htmYour solution of using arrays is wrong if you want to be deleting objects from the middle and concatenating the array.  Arrays are more or less meant for fixed sizes of memory that do not ever change.-me   ;  All right..I'm not comfortable with std 'cause i never used them. But i see that i'll do it shortly. As there really is no possibilities to copy or move an element of a class array, to concatenate it with realloc -realloc working well for me with that type of array- it will be obliged to !But i don't get why "new" doesn't work at all with my class as you all appear to agree with that use. No errors or warnings at the compilation step toward the initialization line of the array, but a bunch of errors saying that the class's variables i try to acces need to have a union/struct/class type ! Leting me guess there were no initialization of my array !What could happened? Even withMyClass **var=new MyClass*[n];orMyClass *var=new MyClass[n];the same errors were found at compilation time..!! any kind of explanations ?   ;  Sorry for the last reply... Everything's fine ! It's all getting interesting.By guys/girls ... for now   