795cda60   
   From: n2xssvv.g02gfr12930@ntlworld.com   
      
   On 01/11/11 10:57, 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.   
   >   
   >   
   > Thanks for any help.   
   >   
   > Thanks,   
   >   
   > Shan   
   >   
   >   
      
    I assume the vector is allocated on construction and therefore freed   
   on destruction. The 'FieldValues' variable will need to be checked if it   
   is NULL before the vector is used/deleted, and reset to NULL after the   
   vector has be deleted.   
    Based on the vector containing dynamically allocated data I would   
   recommend a separate member function to delete the vector contents   
   before deleting the vector. In fact I would recommend you provide member   
   functions to handle/use the vector usage interfaces, in effect creating   
   a user specific container class to fit your requirements.   
      
   cpp4ever   
      
      
   --   
    [ 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)   
|