Very very basic question

I am a student who just started to learn programming with c++. So kindly excuse me if my question is full of nonsense. Thank you. So I wonder what is that line "multiset<int> A(int Arr, intArrr+arrSize);" meaning?

1
2
3
4
int intArr[] = {3, 5, 1, 5, 9, 7, 5, 9};
int arrSize = sizeof(int Arr) / sizeof(int);
multiset<int> A(int Arr, intArr+arrSize);
multiset<int>::iterator it;
Here is the definition of the constructor for multiset: http://www.cplusplus.com/reference/set/multiset/multiset/

Multiset is a container that can hold any type of objects, so multiset<int> just tells you that you store ints.

In this piece of code, you are using the range constructor for A. You need to give it two values: the iterator to the first element, and the iterator to the last element. For arrays (intArr), intArr points to the first element. intArr+arrSize is just simple pointer arithmetic to indicate the last element in the array. Note that on your line 3 you should have intArr not int Arr
Topic archived. No new replies allowed.