- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
1 继承 “继承”这个词的字面含义是: 按照法律或遵照遗嘱接受死者的财产、职务、头衔、地位等。 面向对象方法中的继承与现实世界中的继承的意义基本相同,是指一个类完全继承了另一个类的所有内容,如字段、成员函数等。 继承是一种父母与孩子的关系,孩子从父母那继承了一些父母的特点,并也有着与父母的不同之处。 面向对象的关键特性——继承 继承示例 灯与台灯、壁灯、吊灯之间的继承关系 面向对象的关键特性——继承 继承示例 人与学生、教师、士兵之间的继承关系 class Program { static void Main(string[] args) { B b = new B(); b.Display(); Console.ReadLine(); } } class Program { static void Main(string[] args) { B b = new B(); b.Display(); b.T = hello; b.Dispaly11(); Console.ReadLine(); } } class Program { static void Main(string[] args) { Employee e = new Employee(); e.GetEmployeeInfo(); Console.ReadLine(); } } public class Person { int age; public Person(int age) { this.age=age; } } public class Student : Person { int age,string sex; public Student(int age,string sex): base(age) { this.sex=sex; } } class Program { static void Main(string[] args) { Console.WriteLine(第一次实例化,无参:); Child c = new Child(); Console.WriteLine(); Console.WriteLine(第二次实例化,有参:); Child c1 = new Child(8); Console.ReadLine(); } } class Program { static void Main(string[] args) { Console.WriteLine(第一次实例化,无参:); Child c = new Child(); Console.WriteLine(); Console.WriteLine(第二次实例化,有参:); Child c1 = new Child(8); Console.ReadLine(); Child c2 = new Child(3,4,5); } } public class Person { int age; public Person(int age) { this.age=age; } public void Speak() { Console.writeLine(“speak language”); } } static void Main(string[] args) { Bicycle b = new Bicycle(); b.Wheel(); Tricycle t = new Tricycle(); t.Wheel(); Jeep j = new Jeep();
文档评论(0)