0

How to access operator[] from inside of a derived class in C++?

The following code produces the following error message:

    main.cpp|10|error: no match for 'operator=' 
    (operand types are 'mymap' 
    and 'std::__cxx11::string' 
    {aka 'std::__cxx11::basic_string<char>'})|
    #include <iostream>
    #include <map>

    using namespace std;

    class mymap : public map<char, string> {
        public:
            void add(char c, string s) {
                this[c] = s;
            }
    };
pico
  • 1,398
  • 1
  • 12
  • 39

0 Answers0