Given the following code:
struct A
{
    /*keyword*/ int field;
};

int main()
{
    A a;
    const A& b = a;
    b.field = 0;
    return 0;
}
What access specifier must be in place /*keyword*/ to make the code compile and run successfully?
Explanation
The keyword mutable before the data field allows you to modify the value of this field, even if it is in a constant object.
The keyword static does not fit, because in this case it is necessary to define A::field outside the class so that the linker knows the memory address at which the value of A::field is stored.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes