Pairs with vector

Hello,


I want to use std:: pair with vector, how should it be implemented?

I have this so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 #include <utility>
#include <iostream>
#include <vector>

using namespace std;


int main ()
{
  vector<int> myvector;
  int value;

  do {
    cin >> value;
    myvector.push_back (value);
  } while (myint);

  pair <string,int> value1; ("paper",0);                   
  pair <string,int> value2 ("rock",1);   
  pair <string,int> value3 ("scissors",2);          

  value1 = make_pair(string("paper"),0.);   

  
}



thanks already
I want to use std:: pair with vector
How? store pairs in vector?
std::vector<std::pair<std::string, int>> foo;

Store vectors in pairs?
std::pair<std::string, std::vector<int>> bar;

Something else?
My idea is:

1) The user enters rock, paper or scissors.

2) Then I assign those string values to type int with std:pair

So I would guess that I need to store pairs in vector.

string values to type int
You want to convert strings to corresponding ints? If so, std::map is better for it.
Topic archived. No new replies allowed.