So I only want to use one class Object for all of my functions but I do not want to directly use that class instead I need to access the members of the derived classes.
Take this example:
class A {
public A() {
}
public void DoSomething() { }
}
class B : A {
public B() {
}
public void DoSomethingBetter() { }
}
class C : A {
public C() {
}
public void DoSomethingBest() { }
}
class Runner {
public static void Main(String[] args) {
A objB = new B();
objB.DoSomethingBetter(); //Won't compile
A objC = new C();
objC.DoSomethingBest(); //Won't compile
}
}
I don't want to initialize them as B objB = new B(), that is not the purpose and I already know that that could be a solution. I need to just use the parent class for this.
Thanks
DoSomethinginstead?