Articles → .NET → Why Can't We Instantiate Abstract Class

Why Can't We Instantiate Abstract Class











public abstract class AbstractClass {
  protected AbstractClass(int x) {
    Console.WriteLine("Abstract Constructor");
  }
}




public class DerivedClass: AbstractClass {
  public DerivedClass(int x): base(x) {
    Console.WriteLine(x);
  }
}




DerivedClass cls = new DerivedClass(10);




Picture showing the constructor invocation of abstract class constructor followed by derived class constructor

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, January 11, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250