Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Overloading
//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 class ParentClass { public int ParentMethod(int a, int b) { Console.WriteLine(a+b); return a+b; } //public int ParentMethod(int a, int b) --> Error, already defines a member called 'ParentMethod' with the same parameter types and //{ // same return type //Console.WriteLine(a+b); //return a+b; //} //public string ParentMethod(int a, int b) --> Error, already defines a member called 'ParentMethod' with the same parameter types and //{ // same return type // string aval= a.ToString(); //string bval= b.ToString(); //Console.WriteLine(aval+bval); // return aval+bval; //} public int ParentMethod(int a,int b,int c) { Console.WriteLine(a+b+c); return a+b+c; } } public class ChildClass: ParentClass { public int ParentMethod(int a, int b, int c,int d) { Console.WriteLine(a+b+c+d); return a+b+c+d; } } public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Hello, world!"); ChildClass cc=new ChildClass(); cc.ParentMethod(1,2); cc.ParentMethod(1,2,3); cc.ParentMethod(1,2,3,4); ParentClass pc=cc; pc.ParentMethod(3,4); } } }
run
|
edit
|
history
|
help
0
SHA Tester 2.1
Find Prime number
Fórum PS ➡ Converting a type (class category) to bool, implicitly ♦
Hello world test
-Wall -std=c++14 -O0 -o a.out source_file.cpp
2
Fixing Broken Lines
1
1
ElaineBrown