Atitit 多继承实现解决方案 java c#

Atitit 多继承实现解决方案 java c#

 

Java c#都没有提供多继承的解决方案。。默认从语言级别以及没办法多继承了.

 

只可以崽类库的级别实现拉..

 

继承的原理就是,使用一个内部super指针指向超类..我们可以下定义多个super 指针走ok..

 

 

 

Atitit 使用内部类来实现多继承

使用定义多个super 指针 实现..

super 的命名,还是super前缀,.中间ide里面儿容易的提示..

 

 

当然,没有原生语言的支持,调用方面要多一个层级,稍微麻烦些。不过都用super前缀也会好很多哈。。

 

package com.alipay.config;

 

public class MultiInherSon extends MultiInherParent1  {

MultiInherParent2 super_prt2=new MultiInherParent2();

MultiInherParent1 super_prt3=new MultiInherParent1();

public static void main(String[] args) {

MultiInherSon son=new MultiInherSon();

son.m1();

son.super_prt2.m2();

son.super_prt3.m1();

 

}

 

 

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 

汉字名:艾提拉(艾龙)   EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

Atiend

 

原文地址:https://www.cnblogs.com/attilax/p/15198300.html