K
kelvSYC
If you have an instance of a struct that's marked const, does the const
keyword mean that all of its members are read-only? What if you wanted
a struct where some members are constants and a few others you could
change?
Example:
struct foo {
const int a;
int b;
int (*c)(void);
}
const struct foo bar;
bar.a is constant
Is bar.b constant?
How about bar.c?
What if you wanted to have a structure where a and c are constant, and
b could be changed? Would you have to remove the const when declaring
bar?
keyword mean that all of its members are read-only? What if you wanted
a struct where some members are constants and a few others you could
change?
Example:
struct foo {
const int a;
int b;
int (*c)(void);
}
const struct foo bar;
bar.a is constant
Is bar.b constant?
How about bar.c?
What if you wanted to have a structure where a and c are constant, and
b could be changed? Would you have to remove the const when declaring
bar?