public abstract class AppleBase
{
public AppleBase()
{
}
public abstract void SetPrice();
}
First, if I try to create an object of an abstract class what will happen?
There, it's a compile-time error. forget about running your program, not even complier is ready to allow that.
So basically we can not create an instance to call a constructor. But it is not the only way to call a constructor.
Ever heard about Constructor chaining
Constructor Chaining is a concept when a constructor calls another constructor in the same class or its base class.
Let me explain it to you with an example.
Say we have base class AppleBase which is printing a message in its constructor.
Do'stlaringiz bilan baham: |