795cda60   
   From: no.spam.here@its.invalid   
      
   On 11/1/2011 3:57 AM, Shan wrote:   
   > FieldValues = new vector();   
   >   
   >   
   > I have the above FieldValues in a class as private member. How should   
   > I deallocate the memory allocated by this vector. Also I am populating   
   > the vector with dynamically allocated. I want make sure that   
   > char* memory also deallocated when I destroy the instance of the   
   > class.   
   >   
   >   
   In addition to what has been said... Why are you dynamically allocating   
   the vector to begin with? Unless you populate it, vector takes up   
   very little space.   
      
   Better would be vector FieldValues;   
      
   Also, is your char* data string data, or is it actual arrays of   
   characters?   
      
   In the first case, a better usage would be vector   
   In the second case, better would be vector >;   
      
   Assuming you don't dynamically allocate the vector (as in   
   my first point), then either one of these two solutions   
   provides RAII garbage collection, and then you don't have   
   to worry about cleaning up.   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|