Your Ad Here

Saturday, June 14, 2008

Multilevel Inheritance

/* Program in C# for implementation of multiway inheritance */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inherit
{
class One:Mammal
{
public void Noise()
{
Console.WriteLine("Dog Barks");
}

static void Main(string[] args)
{
One obj = new One();
obj.Eat();
obj.feature();
obj.Noise();
}
}

class Animal
{
public void Eat()
{
Console.WriteLine("Every Animal Eats Something");
}
}

class Mammal : Animal
{
public void feature()
{
Console.WriteLine("Mammal Gives birth to young ones");
}
}
}
//Output

//Every Animal Eats Something
//Mammal Gives birth to young ones
//Dog Barks

No comments: