title: Is this C++ destructor redundant?
body: <p>I've received some C++ code with various structures defined like this:</p>
  
  <pre><code>typedef struct _someStruct_ {
     std::string someString; 
     std::vector&lt;std::string&gt; someVectorOfStrings;
     int  someOtherStuff;
  
     ~_someStruct_()
     {
        someString.clear();
        someVectorOfStrings.clear(); 
     }
  } someStruct; 
  </code></pre>
  
  <p>Is the destructor here completely redundant - if the structure were to be destructed by the default destructor, won't any strings, vectors, etc. be destructed anyway? </p>
  
  <p>If I'd written the code, I wouldn't have thought of adding an explicit destructor here - I'd just let the compiler get on with it. </p>
  
  <p>As I understand it, the only time you might need to create your own destructor in a struct is if any of the members of the structures contain pointers to data that might need cleaning up, or if some extra functionality (e.g. for debugging, logging when a structure gets deleted) is needed. </p>
  
  <p>Am I missing something here - is there any reason why strings and vectors have been explicitly cleared in the destructor? My suspicion is that the person who sent me this is really a C programmer (cf. the typedef) who's tried to turn some C code into C++. </p>