Is encapsulation broken if I use a global variable in the definition of a member function of a class?

I was asked to explain what encapsulation is, and I replied: "Combining data and functions that modify this data is called encapsulation."

The answer was followed by another question: "So, by your definition, if I change a global variable from a member function of a class, then encapsulation is broken."

It made sense to answer YES.

I am not sure if my explanation is incorrect or whether the following question is valid, and my answer to it as YES is correct.

Can someone help.

+4
source share
2 answers

wikipedia:

, :

  • .
  • , ( ), .

, .

, , . , , , , - .

, , , , , .

, , , , .

+1

, .

, , -, , .

, , (static). . , private static.

, , , :

0

All Articles