constless

13, Jan, 2021
struct A {
    mutable int i;
    A() { i =2; }
    void sq() const { i = i * i; }
    void ml(int j) const { i *= j; }
};

int main() {
    const struct A a;
    a.sq();
    a.ml(3);
    a.i = 5;
    return a.I;
}

Why do we use const anyway?