title: Use a list instead of an array in c++
body: <p>I just started to study c++ and I did not get to understand the list. I have some code using the array.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class test {
  public:
  string a,b;
  };
  
  int main(){
  test param [3]; 
  param[0].a = "asdf";
  param[0].b = "ghjk";
  param[1].a = "qwer";
  param[1].b = "tyui";
  param[2].a = "zxcv";
  param[2].b = "vbnm";
  cout &lt;&lt; "param\ta\tb\n";
  for(int i = 0; i&lt;3; i++){
  cout &lt;&lt; i &lt;&lt; "\t" &lt;&lt; param[i].a &lt;&lt;
  "\t" &lt;&lt; param[i].b &lt;&lt; endl;
  }
  }
  </code></pre>
  
  <p>How to realize same code using the list? Below are my attempts to do this:</p>
  
  <pre><code>#include &lt;list&gt;
  ...
  list &lt;test&gt; param;
  param.push_back();
  param.back().a = "asdf";
  param.back().b = "ghjk";
  ...
  </code></pre>
  
  <p>second try:</p>
  
  <pre><code>...
  test o; 
  o.a = "asdf"; o.b = "ghjk";
  param.push_back(o);
  ...
  </code></pre>
  
  <p>As you know, none of them works...</p>