0

As the title said. I'm new to c++. So i wanted to make a map with pair of int as the key and boolean as the value

 map <pair<int,int>,bool>.

how do i assign the value and access it?

SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105

2 Answers2

1

You'll need to pass one std::pair<int,int> object (your comment suggests passing two int objects, but that's no pair yet.)

You can create a std::pair<int,int> like this: std::pair<int,int> {5,7} or figure out the types from the two arguments to std::make_pair(5, 7).

MSalters
  • 173,980
  • 10
  • 155
  • 350
1

The first argument in

map <pair<int,int>, bool> mp;

is a key of pair. Therefore you can assign a value and access it as -

mp[{1,2}] = true;
Dev Pahuja
  • 35
  • 8