g****y 发帖数: 212 | 1 In Class A, I have several private data memebers,
in one public function of A, I take another object B of type A as parameter.
Why can I access B's private member?
For example
public class A
private a1 as Integer
private b1 as Interger
public sub test(byval B as A)
me.a1 = B.a1
~~~~~~
end sub
End class | p***n 发帖数: 635 | 2 it is probably a BUG in the framework or it is "By Design"
【在 g****y 的大作中提到】 : In Class A, I have several private data memebers, : in one public function of A, I take another object B of type A as parameter. : Why can I access B's private member? : For example : public class A : private a1 as Integer : private b1 as Interger : public sub test(byval B as A) : me.a1 = B.a1 : ~~~~~~
| g****y 发帖数: 212 | 3 If it is true.
How can you expect the MSIL code of VB.net and C#.net could be the same?
I assume that c# doesn't have such problem.
parameter.
【在 p***n 的大作中提到】 : it is probably a BUG in the framework or it is "By Design"
| d******p 发帖数: 24 | 4 It is called class-based "private".
It is true for all c++ family language, including
java and C#. While Smalltalk supports what you
what, object-based "private".
BTW, "protected" is different.
【在 g****y 的大作中提到】 : If it is true. : How can you expect the MSIL code of VB.net and C#.net could be the same? : I assume that c# doesn't have such problem. : : parameter.
| s*i 发帖数: 5025 | 5 In C#, you will get the same thing.
I think it is a good thing. By default, the "producer" of class A, who is the
programmer, has all the power to design, implement anything related to A. So
when he is implementing something related to A, he should be able to access
anything.
However, the "consumer", other classes that uses A, should have restricted
access power.
Any senario that this could be a really bad idea?
【在 g****y 的大作中提到】 : If it is true. : How can you expect the MSIL code of VB.net and C#.net could be the same? : I assume that c# doesn't have such problem. : : parameter.
| g****y 发帖数: 212 | 6 en. That means, if I want, I could make the objects of same type access each
other's private member ?
I don't think it is true in C++ or Java.
the
【在 s*i 的大作中提到】 : In C#, you will get the same thing. : I think it is a good thing. By default, the "producer" of class A, who is the : programmer, has all the power to design, implement anything related to A. So : when he is implementing something related to A, he should be able to access : anything. : However, the "consumer", other classes that uses A, should have restricted : access power. : Any senario that this could be a really bad idea?
| s*i 发帖数: 5025 | 7 Only when you are writing code within class A{} scope, you can do that. I am
not sure about Java and C++.
So
access
【在 g****y 的大作中提到】 : en. That means, if I want, I could make the objects of same type access each : other's private member ? : I don't think it is true in C++ or Java. : : the
| g****y 发帖数: 212 | 8 en. That means, if I want, I could make the objects of same type access each
other's private member ?
I don't think it is true in C++ or Java.
【在 d******p 的大作中提到】 : It is called class-based "private". : It is true for all c++ family language, including : java and C#. While Smalltalk supports what you : what, object-based "private". : BTW, "protected" is different.
| g****y 发帖数: 212 | 9 Thanks.
each
is
A.
restricted
same?
【在 s*i 的大作中提到】 : Only when you are writing code within class A{} scope, you can do that. I am : not sure about Java and C++. : : So : access
|
|