コードのバグを探していますが、問題があります。
class a
{
public:
void foo(int a) {}
}
std::set<a*> set;
std::set<a*>::iterator it = set.begin();
it->foo(55); //gives me error:
// error: request for member ‘foo’ in ‘* it.std::_Rb_tree_const_iterator<_Tp>::operator-><a*>()’, which is of pointer type ‘a* const’ (maybe you meant to use ‘->’ ?)
非定数関数を使用できないのはなぜですか?キャストを使用せずに非定数ポインターのセットを作成するにはどうすればよいですか?