Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Abstract Class
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public abstract class absParentClass //public class absParentClass { //public abstract int addition(int a, int b) --> Error, cannot declare a body because it is marked abstract //{ // Console.WriteLine(a+b); // return a+b; //} public int addition(int a, int b) { Console.WriteLine(a+b); return a+b; } public int sub(int a, int b) { Console.WriteLine(a-b); return a+b; } public abstract int mul(int a,int b); public abstract int div(int a,int b); } public class absChildClass: absParentClass { //Before Call Parent Class methods addition and sub , We must implement abstract parent methods under child class. public override int mul(int a, int b) { Console.WriteLine(a*b); return a+b; } public override int div(int a, int b) { Console.WriteLine(a/b); return a+b; } } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); //--> Cannot create an instance of the abstract class or interface absParentClass //absParentClass apc=new absParentClass(); //apc.addition(3,5); absChildClass acc=new absChildClass(); acc.addition(2,3); acc.sub(4,1); acc.mul(3,5); acc.div(20,4); //--> Call the all methods with the reference of Parent Abstract Class. absParentClass apc =acc; apc.addition(2,8); apc.sub(4,1); apc.mul(2,3); apc.div(10,2); } } }
run
|
edit
|
history
|
help
0
Linq & lambdas
Converting a string to byte-array without using an encoding (byte-by-byte)
Huffman Algorithm
FindSmallest
Octavia
Copy_BubbleSort
miner
Addition
Padma narwade
Plt-D v.0.8.1