34. abstaract class and method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abstraction.cs
{
abstract class polyabstr
{
public int h, w;
public abstract int area();
}
class rectangle : polyabstr
{
public rectangle( int h, int w )
{
this.h = h;
this.w = w;
}
public override int area() //without override error is 'abstraction.cs.rectangle' does not implement //inherited abstract member 'abstraction.cs.polyabstr.area()'
{
return base.h * base.w;
}
}
class Program
{
static void Main(string[] args)
{
rectangle obj = new rectangle(10, 20);
Console.WriteLine("Area of Rectangle = " + obj.area());
Console.Read();
}
}
}
Comments
Post a Comment