Why we can't create the object of abstract class ?
1 Virtual PureVirtualFunction()=0;
This indicates compiler to reserve a slot for Function in VTABLE but don’t put an address in that
particular slot. If only one function in a class is declared as pure virtual, the VTABLE is incomplete.
If the VTABLE for a class is incomplete, compiler cannot safely create an object of a pure abstract
class, so you get an error message from the compiler if you try to make an object of a pure abstract
class. Thus, the compiler ensures the purity of the abstract class, and you don’t have to
worry about misusing it.
2 The exact reason is .
The function address of the pure virtual function is not put into VTABLE of the abstract class ,
hence VTABLE of the abstract is incomplete. So when the user tries to create an instance of the
abstract class the compliler will throw an error.
The reason behind this is , the abstract class contains abstract methods which cant do any job.
Calling such function is meaningless. So it is not allowed to instantiate abstract class
abstract class is an incomplete class,because if it have any method which is abstract then it will be
an abstract class, and abstract method have not any implementation,thats why we can not create
any object of the abstract calss,we can not use the sealed keyword with abstract calss
A Simple Real time Example do Child Can Exsist Without Parent? ans is No, Hence we Define an Abstarct Class(Parent) and now the Controvercy is wheater Parent is alive or not? Child have aquried the Properties of
Parent even though if he is alive or not? to Define an Abstract class keep in mind that parent is not
alive that means instance can not be created but can be inherited .....Hence we can not create instance
of abstract class
abstract class contain one or more pure vertual function ,this types of class contain only the declaration of method ,it do not have defination of any method,when we define any abstract class object it not allocate
the memory to any object , and when any object of class will created it first initialise memory for
class and then methods. and look for the defination for that, for that point of view when we
createobject of any abstract class method defination will not present and memory cannot be allow to
object. any by the compiler it cause the error.