Is encapsulation violated, if I use a global variable in a class member function's definition?

Viewed 1537

I've been asked to explain what encapsulation is and I replied "bundling of data and functions that modify this data, is called encapsulation."

The answer was followed by another question—"So, by your definition if I modify a global variable from a member function of a class then the encapsulation is violated."

It made sense to answer YES.

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

Can somebody help.

2 Answers
Related