https://www.cnblogs.com/Bear-Study-Hard/archive/2006/01/09/313551.html 看了上面这篇文章有感,特做了个小样板,以加深对于this在派生类中的理解 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Co…
class Person{ String name; int age; char gender; public Person (String name){ this.name = name; } public Person (String name , int age){ this.name = name; this.age = age; } public Person (String name , int age ,char gender){ this.name = name; this.ag…
请看下面代码: using System; public class A{ public A(){ M1(); } public virtual void M1(){} } public class B : A{ private string _method; public B(){ _method = "B_C"; } public override void M1(){ Console.WriteLine("Type:{0}, in B, {1}",GetTyp…
<面向对象程序设计基础(第二版>李师贤等,第254页:C++语言的基本规则是:创建一个派生类的对象时,如果基类带有构造函数,则先调用基类的构造函数,然后才调用派生类的构造函数. <Thinking in C++>,刘宗田等译,第261页:可以看出,构造在类层次的最根处开始,而在每一层,首先调用基类构造函数,然后调用成员对象构造函数. <C++ Primer Plus(第四版)中文版>,孙建春等译,第399页:记住:创建派生类对象时,程序首先调用基类构造函数,然后再调用派…