[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

object of abstract class

Hi

Why object of abstract class can’t be instantiate?

Regards
Karan Gupta
0
KaranGupta
Asked:
KaranGupta
3 Solutions
 
EyalCommented:
this is how you do object oriented programming :)

http://en.wikipedia.org/wiki/Abstract_type
0
 
sachinpatil10dCommented:
Use of abstract class

Abstract class is specifically designed to be only derived.
Abstract class has pure virtual functions/methods that must be overriden by the class inherits abstract class.
Instantiating a class that has pure virtual functions is pointless.
Abstract class enforces certain hierarchies for all the subclasses.
0
 
sonawanekiranCommented:
According to OOPs, You can not instantiate an abstract class or an interface - you can instantiate one of their subclasses/implementers.


interface I1
{
   void M();
}
abstract class AB
{
   public abstract void M();
}

public class subClass : AB, I1
{
  .....
}

new subClass(); //OK
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now