"... By the way, Mark Linton came to my office and made an impressive request to provide a third level of control, to support the styles used in the Interviews library being developed by Stanford University. Let's speculate together to create the word protected to represent some Members in the class ,..."
"... Mark is the main designer of Interviews. His persuasive argument is based on actual experience and examples from real code ...."
"... About five years later, Mark banned protected data members in Interviews because they have become the root cause of many program errors ..."
I don't like protected, but today, when I use C ++ occasionally, there is no more cleanliness. It is difficult to use C ++ to make a stable design. The key is not to use C ++ as a special core.
Today, I encountered a problem related to protected. I think it can be written. This is a basic problem and seems familiar to me. After all, I haven't touched it for many years, and I am a little unfamiliar with the C ++ syntax.
When I was a child, I thought this code was illegal.
Because I am worried that the private member variable a of f cannot be accessed in foo: foobar.
Later, I understood that the so-called private is for classes, not specific objects.
But I encountered another problem today.
This time, in foobar: bar, the member accessing this is allowed, but the member of f is forbidden.
Because foo: a is protected for foobar, the member function of foobar can access its own a, but it is forbidden for the foo pointer.
Think about the solution.
Bad taste. However, this is not the case.