C#多重继承(多层次继承)
using System;
/// <summary>
/// C#多重继承
/// </summary>
namespace MultipleInheritance
{
//线
class Line
{
protected int length;
public Line(int l = 0)
{
length = l;
}
public int area()
{
return length;
}
}
//方形
class Rectangle : Line
{
protected int width;
public Rectangle(int l = 0, int w = 0) : base(l) {
width = w;
}
public new int area()
{
return width * length;
}
}
//方体
class Cube : Rectangle
{
private int height;
public Cube(int l = 0, int w = 0, int h = 0) : base(l, w) {
height = h;
}
public new int area()
{
return width * length * height;
}
}
class RectangleTester
{
static void Main(st