title: What is the advantage of dynamic memory control?
body: <p>For example, I want to make a stack. I can do it in that way, using the dynymic memory control, with <code>new</code> and <code>delete</code> opereations: </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  struct List
  {
      int x; 
      List *Next,*Head; 
  };
  
  
  void Add(int x, List *&amp;MyList)
  {
      List *temp=new List; 
      temp-&gt;x=x; 
      temp-&gt;Next=MyList-&gt;Head; 
      MyList-&gt;Head=temp; 
  }
  
  
  void Show(List *MyList) 
  {
      List *temp=MyList-&gt;Head; 
  
      while (temp!=NULL) 
      {
      cout&lt;&lt;temp-&gt;x&lt;&lt;" "; 
      temp=temp-&gt;Next; 
      }
  }
  
  
  void ClearList(List *MyList)
      {
      while (MyList-&gt;Head!=NULL) 
      {
      List *temp=MyList-&gt;Head-&gt;Next; 
      delete MyList-&gt;Head; 
      MyList-&gt;Head=temp; 
  }
  }
  
  int main()
  {
  
  
      List *MyList=new List; 
  
  
      MyList-&gt;Head=NULL; 
  
      for (int i=0;i&lt;10;i++) Add(i,MyList); 
      Show(MyList); 
  
      ClearList(MyList); 
      delete MyList-&gt;Head;
      delete MyList;
  }
  </code></pre>
  
  <p>And also I can just make a stack in that way and do anything with it:</p>
  
  <pre><code>std::stack&lt;int&gt; MyStack;
  </code></pre>
  
  <p>So, which one is better? What is the advantage of a stack with dynamic memory allocation? In what cases should I use first/second variants? </p>