C++ “error: passing 'const std::map >' as 'this' argument of …”

后端 未结 3 1937
清酒与你
清酒与你 2020-12-03 18:02

With the following code (excerpted for brevity):

color.h:

class color {
public:
    color();

    enum colorType {
        black, blue, green, cyan,          


        
3条回答
  •  猫巷女王i
    2020-12-03 18:20

    The key is near the end: "discards qualifiers". getColorText is a const member function, so colors is const. But map::operator[]() is not const.

提交回复
热议问题