title: Best practice when calling initialize functions multiple times?
body: <p>This may be a subjective question, but I'm more or less asking it and hoping that people share their experiences. (As that is the biggest thing which I lack in C++)</p>
  
  <p>Anyways, suppose I have -for some obscure reason- an initialize function that initializes a datastructure from the heap:</p>
  
  <pre><code>void initialize() {
      initialized = true;
      pointer = new T;
  }
  </code></pre>
  
  <p>now When I would call the initialize function twice, an memory leak would happen (right?). So I can prevent this is multiple ways:</p>
  
  <ul>
  <li>ignore the call (just check wether I am initialized, and if I am don't do anything)</li>
  <li>Throw an error</li>
  <li>automatically "cleanup" the code and then reinitialize the thing.</li>
  </ul>
  
  <p>Now what is generally the "best" method, which helps keeping my code manegeable in the future?</p>
  
  <p><strong>EDIT</strong>: thank you for the answers so far. However I'd like to know how people handle this is a more generic way. - How do people handle "simple" errors which <strong>can</strong> be ignored. (like, calling the same function twice while only 1 time it makes sense).</p>