using System;
class Vehichle;
{
public int wheels;
protected float weight;
public Vehichle(){;}//什么意思?不明白?
public Vehicle(int w,float g)
{
wheels=w;
weight=g;
}
public void Show()
{
Console.WriteLine("the wheel of vehicle if:{0},wheels");
Console.WriteLine("the wheel of vehicle if:{0},weight");
}
}
class Car:Vehicle
{
int passengers;
public Car(int w,float g,int p):base(w,g) //下面的传递的参数到底运行的是Car还是base里的呀?
{
wheels=w;
weight=g;
passengers=p;
}
new public void Show()
{
Console.WriteLine("the wheel of car is:{0},wheels");
Console.WriteLine("the weight of car is:{0},weight");
Console.WriteLine("the Passengers of car is:{0},Passengers");
}
}
class Test
{
public static void Main()
{
vehicle V1=new Vehicle(4,5);//它传递的参数不是4,5吗?为什么会得到下面的结果呀?
Car c1=new Car(4,2,4);
v1.show();
c1.show();
}
}
运行结果:
the wheel of vehicle is:0
the weight of vehicle is:0
the wheel of car is:4//下面的几个还好像有点明白.
the weight of car is:2
the Passengers of car is:4