Program to implement Run-time polymorphism using virtual function concept
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication32
{
class a
{
public int s, r;
public virtual void add()
{
s = 23;
r = 56;
Console.WriteLine(s);
Console.WriteLine(r );
Console.WriteLine("base class a");
}
}
class b:a
{
public override void add()
{
s = 389;
r = 7648;
Console.WriteLine(s);
Console.WriteLine(r);
Console.WriteLine("derived class b");
}
}
class c:a
{
static void Main(string[] args)
{
b b1 = new b();
b1.add();
c c1 = new c();
a a1 = new a();
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment