title: how to use lists with class/struct variables in c++
body: <p>I have a running <code>C#</code> program provided below. I'm trying to convert it into <code>C++</code>, but having trouble getting desired output although there are no compilation errors in <code>C++</code> program given below.</p>
  
  <p>The <code>C#</code> program I am trying to convert is:</p>
  
  <pre><code>class Evl_token
  {
      public enum Token_type { NAME, NUMBER, SINGLE };
      public Token_type type;
      public string str;
      public int line_no;
  }; // class evl_token
  
  List&lt;Evl_token&gt; tokens = new List&lt;Evl_token&gt;()
          {
              //input is below 
              //line 1 module top;
              //line 2 wire in,out;
              //line 3 not(out,in);
              //line 4 endmodule
  
              new Evl_token {line_no = 1, str = "module", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 1, str = "top", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 1, str = ";", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 2, str = "wire", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 2, str = "in", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 2, str = ",", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 2, str = "out", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 2, str = ";", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 3, str = "not", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 3, str = "(", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 3, str = "out", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 3, str = ",", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 3, str = "in", type = Evl_token.Token_type.NAME},
              new Evl_token {line_no = 3, str = ")", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 3, str = ";", type = Evl_token.Token_type.SINGLE},
              new Evl_token {line_no = 4, str = "endmodule", type = Evl_token.Token_type.NAME},
          };
  </code></pre>
  
  <p>The corresponding <code>C++</code> program I figured out is below:</p>
  
  <pre><code>struct evl_token
  {
      enum token_type { NAME, NUMBER, SINGLE };
      token_type type;
      std::string str;
      int line_no;
  }; //struct evl_token
  
  typedef std::list&lt;evl_token&gt; evl_tokens;
  
  evl_tokens tokens;
  
  evl_token token;
  
  //{
      //input is below 
      //line 1 module top;
      //line 2 wire in,out;
      //line 3 not(out,in);
      //line 4 endmodule
      token.line_no = 1, token.str = "module", token.type = evl_token::NAME,
      token.line_no = 1, token.str = "top", token.type = evl_token::NAME,
      token.line_no = 1, token.str = ";", token.type = evl_token::SINGLE,
      token.line_no = 2, token.str = "wire", token.type = evl_token::NAME,
      token.line_no = 2, token.str = "in", token.type = evl_token::NAME,
      token.line_no = 2, token.str = ",", token.type = evl_token::SINGLE,
      token.line_no = 2, token.str = "out", token.type = evl_token::NAME,
      token.line_no = 2, token.str = ";", token.type = evl_token::SINGLE;
      token.line_no = 3, token.str = "not", token.type = evl_token::NAME,
      token.line_no = 3, token.str = "(", token.type = evl_token::SINGLE,
      token.line_no = 3, token.str = "out", token.type = evl_token::NAME,
      token.line_no = 3, token.str = ",", token.type = evl_token::SINGLE,
      token.line_no = 3, token.str = "in", token.type = evl_token::NAME,
      token.line_no = 3, token.str = ")", token.type = evl_token::SINGLE,
      token.line_no = 3, token.str = ";", token.type = evl_token::SINGLE,
      token.line_no = 4, token.str = "endmodule", token.type = evl_token::NAME;
  //}
  tokens.push_back(token);
  </code></pre>
  
  <p>The Output I get in case of <code>C++</code> program only shows last line which is line <code>4</code>,how should I work with lists in case of <code>C++</code> that my list gives me desired output?</p>