Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

about 10 years ago

Language

Compiler

Options

Author

anonymous

about 10 years ago

$
prog.cc: In member function 'void A::f(const string&) const':
prog.cc:11:45: error: passing 'const std::map<std::__cxx11::basic_string<char>, double>' as 'this' argument discards qualifiers [-fpermissive]
         cout << "m[" << key << "]=" << m[key] << endl;
                                             ^
In file included from /usr/local/gcc-head/include/c++/6.0.0/map:61:0,
                 from prog.cc:2:
/usr/local/gcc-head/include/c++/6.0.0/bits/stl_map.h:474:7: note:   in call to 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = double; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, double> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = double; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::__cxx11::basic_string<char>]'
       operator[](const key_type& __k)
       ^~~~~~~~
prog.cc: In function 'int main()':
prog.cc:25:9: error: no matching function for call to 'A::f()'
     a.f();
         ^
prog.cc:9:10: note: candidate: void A::f(const string&) const
     void f(const string& key) const
          ^
prog.cc:9:10: note:   candidate expects 1 argument, 0 provided
Exit Code:
1