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; …