title: Better to allocate on the stack or heap within a class
body: <p>This was more of a conceptual question, but I'll provide a particular instance where I'm wondering about this. If I have a class that has several objects as properties, is it better to allocate them statically within the class, or dynamically during construction? For example, I have the following class (unecessary code emitted)</p>
  
  <pre><code>class OutlinedText
  {
  protected:
      sf::Text BaseText;
      sf::Text BackgroundText;
  }
  </code></pre>
  
  <p>sf::Text are both objects as well. My question is, is it better to have them as declared above, and initialize them as follows</p>
  
  <pre><code>OutlinedText::OutlinedText(std::string &amp;text, sf::Color MainColor, sf::Color OffsetColor, sf::Font &amp;font, sf::Vector2f Pos, unsigned int BaseFontSize, unsigned int BackFontSize, float Offset)
  {
      BaseText = sf::Text(text, font, BaseFontSize);
      BaseText.SetColor(MainColor);
      BackgroundText = sf::Text(text, font, BackFontSize);
      BackgroundText.SetColor(OffsetColor);
  }
  </code></pre>
  
  <p>or, should i have them as pointers and allocate them with new as follows:</p>
  
  <pre><code>BaseText = new sf::Text(text, font, BaseFontSize);
  BaseText-&gt;SetColor(MainColor);
  </code></pre>
  
  <p>and deallocate them with delete in the destructor? I know the stack allocates memory alot faster, but I think I'm double initializing the way I have now. SO is it a case by case thing or is one always better then the other? I'm still used to the C# way of doing things, so I was curious what the proper way to do this for C++ is. If I have a fundamental misunderstanding, please correct me.</p>
  
  <p>Thanks in advance</p>