1

I am trying to put 2 arguments inside a vector using push_back but its giving me an error since the function is allowed to take only one argument. How can I pass 2 arguments??

Vertex Class:

template <class VertexType, class EdgeType> class Vertex{
public:
std::vector<std::pair<int, EdgeType>> VertexList;
};

Outside Vertex Class inside Main():

project3::Vertex<string, string> v1("v1");
v1.VertexList.push_back(1,"e1");

Error is :

error C2661: 'std::vector<_Ty>::push_back' : no overloaded function takes 2 arguments IntelliSense: too many arguments in function call

tech_human
  • 6,592
  • 16
  • 65
  • 107

2 Answers2

1

You need to do

v1.VertexList.push_back(std::pair<int, EdgeType>(1,"e1"));
Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
1

Try push_back(make_pair(1, string("e1")));

Guy Sirton
  • 8,331
  • 2
  • 26
  • 36