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.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести