Как в производном классе сделать переменную private, которая в родительском классе была pablic.
делаю так
class Program
{
static void Main(string[] args)
{
Point2D ptA = new Point2D();
Point3D ptB = new Point3D();
Console.WriteLine("x = {0} y = {1} z = {2}", ptA.x, ptA.y, ptA.z);
Console.WriteLine("x = {0} y = {1} z = {2}", ptB.x, ptB.y, ptB.z);
Console.ReadKey();
}
}
class Point2D:Point3D
{
private new double z=5;
public Point2D(){
x = 1;
y = 2;
z = 5;}
}
class Point3D
{
public double x, y, z;
public Point3D(){x = y =z = 0;}
}
но z в Point2D остается public, так еще ей не присваивается значение 5, остается 0.
... << RSDN@Home 1.1.4 stable SR1 rev. 568>>