2 ms·
From one point of view, yes. Another point of view is that it's a new kind of de-encapsulation. Apparently this is a 'global' variable: int variable = 0;
by mrkeen 2y ago
From one point of view, yes.
Another point of view is that it's a new kind of de-encapsulation.
Apparently this is a 'global' variable:
int variable = 0;
void foo() {
variable++;
}
void bar() {
variable++;
}
but this is an 'encapsulated' variable:
class MyClass {
int variable = 0;
void foo() {
variable++;
}
void bar() {
variable++;
}
}
You can block the top one in a code-review because "global variable", and tell the developer to fix it by passing the variable in and out of functions when needed, but I have a feeling the bottom one's getting merged even if you object on the same grounds.