Зачем компилятор жалуется на указанную строку?Почему я получаю ошибку -fpermissive с этим кодом?
class C
{
std::string s;
public:
C() { s = "<not set>";}
~C() {}
void Set(const std::string ss) { s=ss; }
const std::string Get() { return s; }
C &operator=(const C &c) { Set(c.Get()); return *this; }
//error: passing ‘const C’ as ‘this’ argument of ‘const string C::Get()’
// discards qualifiers [-fpermissive]
//C &operator=(C &c) { Set(c.Get()); return *this; } <-- works fine
};
'-fpermissive' не является ошибкой, это флаг для управления сгенерированными ошибками. См. [Что делает флаг fpermissive?] (Http://stackoverflow.com/questions/8843818/what-does-the-fpermissive-flag-do) –