Странная ошибка, установите :: begin () всегда возвращает константный итератор

Почему set.begin () всегда возвращает константный итератор, а не стандартный?

35 int test(){
36     std::set<int> myset;
37     myset.insert(2);
38     myset.insert(3);
39     int &res = *myset.begin();
40     return res;
41 }


test.cpp:39: error: invalid initialization of reference of type ‘int&’ from expression of type ‘const int’
5
задан I-man 31 October 2010 в 19:56
поделиться