×

Loading...

Let me try it.

A compiler error will be generated.

In the method "add" in class "AClass", the variable "ref" refers to another object rather than the object who executes this method. Thus a call to "ref.x" is invalid, because x is a private member.

I admit this program is quite tricky, and it's helpful for us new learner.

Thanks peterlf.
Sign in and Reply Report

Replies, comments and Discussions: