Can we leave a virtual function in an abstract class without implementing in the derived class

Does c# support pure virtual function?
No.
Instead you can use abstract function which is also called as a pure virtual function.
abstract class abTest
{
public abstract void a();

}

Can we leave a virtual function in an abstract class without implementing in the derived class ?
No. It will throw an error.

using System;
using System.Collections.Generic;
using System.Text;

namespace OppTest4
{
abstract class abTest
{
public abstract void a();

}

class UsesabTest : abTest
{
//public override void a()
//{
// Console.Out.Write("a");
//}

public void x()
{
Console.Out.Write("x");
}
}

class Program
{
static void Main(string[] args)
{
}
}
}

0 comments:

Post a Comment