Why we can't create the object of abstract class ?
Answer Posted / abhishek ajmera
When we declare a pure virtual function like this:-
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.
| Is This Answer Correct ? | 10 Yes | 1 No |
Post New Answer View All Answers
What is array c#?
What is the difference between func and action delegate?
What is a property in c#?
What is cshtml extension?
Why do we need to serialize data?
Can derived classes have greater accessibility than their base types?
What is different between Boxing and Unboxing?
How many bytes is an int in c#?
Do events have return type c#?
Does c# support try-catch-finally blocks?
Enlist all the components of an ado.net framework?
What is the use of console?
What does static mean in c sharp?
Which operator cannot be overloaded in c sharp?
Can a class or a struct have multiple constructors?