A have the following code:
struct abc {
abc(int a) : a(a) {}
int operator [] (int t) {
return t;
}
int a;
};
int main()
{
abc const abc1(25);
int c = abc1[75];
return 0;
}
The error is "passing ‘const abc’ as ‘this’ argument discards qualifiers [-fpermissive]". I dont understand why this error appears? I do not change the fields of the const structure.
If i write abc abc1(25); instead of abc const abc1(25); it's no error.