国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【轉載】#344

2019-11-17 03:18:27
字體:
來源:轉載
供稿:網友

【轉載】#344 - Hidden Base Class Member Is Invoked Based on Declared Type of Object

When you use the new modifier to hide a base class method, it will still be called by objects whose type is the base class. Objects whose type is the derived class will call the new method in the derived class.

1 Dog kirby = new Dog("kirby", 15);2 3 // Calls Dog.Bark4 kirby.Bark();5 6 Terrier jack = new Terrier("Jack", 17);7 8 // Calls Terrier.Bark9 jack.Bark();

The Terrier.Bark method is invoked because the variable jack is declared to be of type Terrier.

We could also use a variable of type Dog (the base class) to refer to an instance of a Terrier (the derived class). If we then call the Bark method using this base class variable, the Bark method in the base class is called, even though we're invoking the method on an instance of the derived class.

1 Dog kirby = new Dog("kirby", 15);2 3 // Calls Dog.Bark4 kirby.Bark();5 6 Dog jack = new Terrier("Jack", 17);7 8 // Calls Dog.Bark9 jack.Bark();

原文地址:#344 - Hidden Base Class Member Is Invoked Based on Declared Type of Object


上一篇:【轉載】#346

下一篇:【轉載】#335

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亳州市| 崇仁县| 三穗县| 崇明县| 陆丰市| 杭锦后旗| 乌兰察布市| 抚顺市| 平原县| 会宁县| 吉安市| 麻城市| 安岳县| 吉木萨尔县| 桑植县| 桃江县| 金华市| 岳阳县| 富阳市| 衡山县| 余姚市| 康乐县| 噶尔县| 安阳县| 阿尔山市| 汝州市| 石阡县| 康保县| 汶上县| 华亭县| 平阳县| 泰兴市| 孟州市| 北辰区| 左权县| 富蕴县| 大冶市| 平乐县| 名山县| 乌什县| 峡江县|