私はc++で知っていますが、継承は「パブリック」、「プライベート」、「保護」のいずれかであり、次のようにクラスAをクラスBにパブリックに継承するかどうかを意味します。
class A
{
public int pub1;
private int prvt1;
protected int proc1;
}
class B : public A
{
//public int pub1;//This variable is because of inheritacne and is internal.
//public int proc1;//This variable is because of inheritacne and is internal.
public int pub2;
private int prvt2;
protected int pro2;
}
つまり、クラスAの2つの変数(pub1、proc1)は継承されましたが、アクセス指定子はパブリックです。しかし、C#では次のようになります
class A
{
public int pub1;
private int prvt1;
protected int proc1;
}
class B : A
{
//public int pub1; //This variable is because of inheritacne and is internal.
//protected int proc1;//This variable is because of inheritacne and is internal.
public int pub2;
private int prvt2;
protected int pro2;
}
つまり、クラスAの2つの変数(pub1、proc1)が継承されましたが、アクセス指定子はクラスAにあったものと同じです。
なぜこの種の実装が.NETFrameworkで提供されているのですか。これの長所と短所は何ですか?