5
C ++ карта відкидає класифікатори доступу (const)
Наступний код каже , що проходячи карту , як constв operator[]відбіркові метод відкидає: #include <iostream> #include <map> #include <string> using namespace std; class MapWrapper { public: const int &get_value(const int &key) const { return _map[key]; } private: map<int, int> _map; }; int main() { MapWrapper mw; cout << mw.get_value(42) << …