Note that there are some explanatory texts on larger screens.

plurals
  1. POpassing vector container to other functions
    primarykey
    data
    text
    <p>This question is a continuum from <a href="https://stackoverflow.com/questions/13783090/sigbart-error-vectorlistmyclass">this one</a><br> I have a vector of lists in my Node class that are not being passed to other functions.</p> <p>Here is the Node.h</p> <pre><code>#include "MyGraph.h" //The Node Class will take the information from the graph class and //convert the information into a format so we can perform DFS on our //graph. enum VertexState { White, Gray, Black }; class Node { private: string nodeId; VertexState status; //whether or not the vertex Node has been visited or not vector&lt;Node&gt; nodeList; vector&lt;list&lt;Node&gt; &gt; *edgeList; public: Node(): nodeId(), status(){} //copy constructor Node(string vertex){ nodeId=vertex; status = White; } ~Node(){} //Setter and Getter methods for our class variables void setId(string vertex){ nodeId = vertex; } void setStatus(VertexState newStatus){ status = newStatus; } string getNodeId(){ return nodeId; } VertexState getStatus(){ //status == White then it is not visited //status == Gray its being processed //status == Black then it has been visited return status; } vector&lt;Node&gt; getNodeList(){ return nodeList; } vector&lt;list&lt;Node&gt; &gt; getEdgeList(){ return *edgeList; } //create nodes from vertex list in the graph object void createNodeList(MyGraph graphObject){ vector&lt;string&gt; vertexList; vertexList = graphObject.getVertexList(); vector&lt;string&gt;::iterator it; vector&lt;Node&gt;placeNodeList; for (it = vertexList.begin(); it !=vertexList.end(); it++){ Node newNode(*it); placeNodeList.push_back(newNode); } nodeList = placeNodeList; cout &lt;&lt; "Size of initial nodeList: " &lt;&lt; nodeList.size()&lt;&lt;endl; } //creates container for edge lists from the graph object void createEdgeList(MyGraph graphObject){ vector&lt;list&lt;string&gt; &gt; newEdgeList; newEdgeList = graphObject.getEdgeList(); vector&lt;list&lt;Node&gt; &gt; myEdgeList; vector&lt;list&lt;string&gt; &gt;::iterator it; for (it = newEdgeList.begin() ; it != newEdgeList.end(); it++) { list&lt;string&gt; edgeString; list&lt;string&gt;::iterator eIt; edgeString =*it; list&lt;Node&gt; edgeContainer; //creates a list container to be pushed on to our edgeList variable for (eIt = edgeString.begin(); eIt != edgeString.end(); eIt++) { Node newNode(*eIt); edgeContainer.push_back(newNode); } myEdgeList.push_back(edgeContainer); } edgeList = &amp;myEdgeList; cout &lt;&lt; "Size of intial edgeList: "&lt;&lt;edgeList-&gt;size() &lt;&lt;endl; } //The operational methods that will work on the Nodes of the graph vector&lt;Node&gt; dephtFirstSearch(Node vertex);//will determine if our graph is connected. vector&lt;Node&gt; DFS2(vector&lt;Node&gt; copyNodeList); bool isGraphConnected(vector&lt;Node&gt; nodeList); bool isEdgeConnected(Node vertex1, Node vertex2);//will determine if there is an edge between two nodes bool findElementaryCycles(); void findArticulationPoints(); void removeVertex(Node myNode, vector&lt;Node&gt;copyNodeList, vector&lt;list&lt;Node&gt; &gt;copyEdgeList); }; </code></pre> <p>When I try to call vector edgeList in my other functions using: edgeList->empty; The function is empty when it shouldn't be. The createEdgeList function is called every time i need it to be used so its not empty. How do I pass the data from my private variable to the functions?</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.
 

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