Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure if I'm getting what is what you want to get, but if you want to save each element of type <code>Node</code> with a different identifier you may try the next:</p> <pre><code>pair&lt;char, Node&gt; node_with_name; </code></pre> <p>And then you can assign the name to the first element doing <code>build &gt;&gt; node_with_name.first;</code> , then put the rest of the elements in the node and assign it in the same way to the second position of the <code>pair</code>.</p> <p>And the vector should also be changed in order to use this solution:</p> <pre><code>std::vector&lt;pair&lt;char, Node&gt; &gt; nodes; </code></pre> <p>And finally you would do:</p> <pre><code>nodes.push_back(node_with_name); </code></pre> <p>in every iteration of the loop.</p> <hr> <p><strong>Edit:</strong> I think that a <code>map</code> would possibly fit better to your needs. I will show you an example:</p> <pre><code>std::map&lt;char,Node&gt; mymap; do { char name; // to store temporarily each node's name build &gt;&gt; name; build &gt;&gt; mymap[name].north; // we start getting the data for the node with this name build &gt;&gt; mymap[name].east; build &gt;&gt; mymap[name].south; build &gt;&gt; mymap[name].west; }while(! build.eof()); </code></pre> <p>And then you can output each node's data with:</p> <pre><code>std::cout &lt;&lt; "mymap['A'].north is " &lt;&lt; mymap['A'].north &lt;&lt; '\n'; </code></pre> <p>Map reference: <a href="http://www.cplusplus.com/reference/map/map/operator%5B%5D/" rel="nofollow">http://www.cplusplus.com/reference/map/map/operator%5B%5D/</a></p> <p>Pair Reference: <a href="http://www.cplusplus.com/reference/utility/pair/" rel="nofollow">http://www.cplusplus.com/reference/utility/pair/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload