-1

I'm relatively new to C++. I'm trying to declare a multiset that contains arrays of size 2. I've tried the following but I don't think it does what I want it to do:

multiset<int> nameOfSet[2];

Can someone please tell me what this line does? If this is wrong, please explain to me why and tell me how to do it correctly. Thanks in advance.

discovery
  • 43
  • 6
  • 4
    The line is declareing a 2-element array of `multiset`. You may want `multiset > nameOfSet;`. – MikeCAT Jul 21 '21 at 15:04

1 Answers1

2
multiset<int> nameOfSet[2];

Can someone please tell me what this line does?

It declares a variable that is an array of two multisets of int.

How do I declare a Multi-set that contains arrays of a certain size?

You cannot. Arrays cannot be elements of any standard container.

However, arrays can be members of classes, and classes can be elements of containers. There is a standard template for such array wrapper: std::array. So, you can do:

std::multiset<std::array<int, 2>> nameOfSet;
eerorika
  • 232,697
  • 12
  • 197
  • 326