Tuesday, August 14, 2012

virtual inheritance and runtime polymorphism

// Using dot net and C#
using System;

public class a
{
    public void Hockey()
    {
        Console.WriteLine("A play hockey");
    }

    public virtual void education()
    {
        Console.WriteLine("MBBS");
    }

}
public class b:a
{
    public void cricket()
    {
        Console.WriteLine("B play cricket");
    }
    public override void education()
    {
        Console.WriteLine("MCA");
    }
}

class demo
{
    public static void Main()
    {
        a a1=new b();            //run time polymorphism
        a1.education();
        Console.ReadLine();
    }
}


OUTPUT:

To see in c++ CLICK HERE

No comments:

Post a Comment