how to initialize private members of class in c++ <p>Hi i have a c++ class with some private members as follows</p> <pre><code> template &lt;typename V, typename E&gt; class Vertex { public: Vertex(); ~Vertex(); typedef std::pair&lt;int, E&gt; edgVertPair; typedef std::vector&lt;edgeVertPair&gt; vectEdges; void setVertexID(int data); int getVertexID(); void setEdgeVertPair(int vertID, E edge); edgVertPair getEdgeVertPair(); void setEdgeList(edgeVertPair edgeVert); vectEdges getEdgeList(); private: int vertexID; edgVertPair evp; vectEdges edgeList; }; </code></pre> <p>Now i want to create a pair i.e. something like </p> <p><code>evp.first="someint"; evp.second="somestring";</code></p> <p>and then push this evp into the edgeList i.e. edgeList.push_back(evp); Now the problem is in the setter function i did something like this:</p> <pre><code> template&lt;typename V, typename E&gt; void Vertex&lt;V, E&gt;::setEdgeVertPair(int vertID, E edge){ ...populate evp;... } </code></pre> <p>now i don't know how to populate the evp pair with vertID, edge. </p>