0% found this document useful (0 votes)
17 views1 page

Abstract Classes

The document defines a namespace containing interfaces and abstract classes for mathematical operations. It includes an abstract class hierarchy with methods for addition, subtraction, and multiplication, implemented in a derived class. The main program demonstrates the use of these classes and methods to perform calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Abstract Classes

The document defines a namespace containing interfaces and abstract classes for mathematical operations. It includes an abstract class hierarchy with methods for addition, subtraction, and multiplication, implemented in a derived class. The main program demonstrates the use of these classes and methods to perform calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

namespace AbstractClasses

{
interface ICalculate1
{

}
interface ICalculate2
{

}
interface ICalculate3: ICalculate1, ICalculate2
{

}
abstract class MyClass:MyClass1, ICalculate1,ICalculate2,ICalculate3
{

abstract class MyClass1


{
public int age;
public void Add(int n1,int n2)
{
int sum = n1 + n2 + age;
[Link]("Sum is {0}", sum);
}
public abstract int Sub(int n1, int n2);
}

abstract class MyClass2 : MyClass1


{
public abstract int Prod(int n1, int n2);
}

class MyClass3 { }
class Derived :MyClass2
{
public override int Sub(int n1, int n2)
{
return n1 - n2;
}
public override int Prod(int n1, int n2)
{
return n1 * n2;
}
}

internal class Program


{
static void Main(string[] args)
{
MyClass2 obj2 = new Derived();
[Link](34, 56);
[Link]("Sub is {0}",[Link](23,21));
[Link]("Prod is {0}", [Link](23,4));
}
}
}

You might also like