Protected поле - C#
Формулировка задачи:
Как обратится к члену с модификатором protected из производного класса?
{
class Program
{
static void Main(string[] args)
{
Derivative D=new Derivative(6);
D.T=new Test(5);
D.T.Write();
D.Write();
Console.ReadLine();
}
}
class Test
{
public int x;
protected int y;
private int z;
public Test (int Y)
{
y = Y;
}
public void Write()
{
Console.WriteLine( this.y);
}
}
class Derivative:Test
{
public Test T;
public Derivative(int x ):base(x)
{
// T.y=10; не дает обратиться
}
}
}Решение задачи: «Protected поле»
textual
Листинг программы
class Derivative:Test
{
public Test T;