C++: Using a multiset?

multiset<myStruct> set1;
multiset<myStruct>::iterator it;
myStruct arr[10];

struct myStruct{
double amount;
int count;
} ;

myStruct apple;
apple.amount = 2.0;
apple.count = 1;

I can do this : arr[0] = apple;

But I can't do this: set1.insert(apple); //Won't work because I can't even compile.

Can someone spot what it is that I'm doing wrongly?

I need to use a multiset because I don't want to contain my data in a predefined structure such that of the array with size 10 or size 100.
multiset keeps the element sorted so it needs a way to compare two elements. Define an operator< for comparing two myStruct objects or pass a comparator as a template argument.

If you only try to avoid a fixed size you better use another container like vector.
Topic archived. No new replies allowed.