Multiple Inheritance:
Multiple inheritance may allow you to write compact code but it has some program difficulties like "diamond problem" for example
Diamond problem :
class BaseClass
{
public abstract void Display();
}
class A : BaseClass
{
public override void Display()
{
Debug.WriteLine("First Child A");
}
}
class B : BaseClass
{
public override void Display()
{
Debug.WriteLine("Second Child B");
}
}
//Now Suppose that c# support multiple inheritance
class C : A, B
{
}
public class MainClass
{
public static void main()
{
C ObjC =new C();
ObjC.Display();
}
}
By excuting ObjC.Display() method Diamond problem is generated. It means which Display method going to executed.
Subscribe to:
Post Comments (Atom)
1 comment:
very informative blog on dotnet....
keep up the gud work....
take care
Post a Comment