#2
扫地大爷2021-07-24 07:06
|
程序代码:
class Program
{
static void Main(string[] args)
{
C yu = new C();
}
}
class A
{
public A()
{ int a;
a = 1; Console.WriteLine("我是A构造函数"); }
~A() { Console.WriteLine("调用A析构函数"); }
}
class B : A
{
private int b;
public B()
{ b = 1; Console.WriteLine("我是基于B派生类B类B构造函数");}
~B() { Console.WriteLine("我是调用B析构函数"); }
}
class C : B { private int c;
public C() { c = 1; Console.WriteLine("我是基于C派生类C类C构造函数"); }
~C() { Console.WriteLine("我是C析构函数"); }
}
}
{
static void Main(string[] args)
{
C yu = new C();
}
}
class A
{
public A()
{ int a;
a = 1; Console.WriteLine("我是A构造函数"); }
~A() { Console.WriteLine("调用A析构函数"); }
}
class B : A
{
private int b;
public B()
{ b = 1; Console.WriteLine("我是基于B派生类B类B构造函数");}
~B() { Console.WriteLine("我是调用B析构函数"); }
}
class C : B { private int c;
public C() { c = 1; Console.WriteLine("我是基于C派生类C类C构造函数"); }
~C() { Console.WriteLine("我是C析构函数"); }
}
}