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
Is c# dictionary a hash table?
How does split work in c#?
Can arraylist hold primitive types?
What is difference between Trace and Debug
When Should You Call The Garbage Collector In .net?
Explain the Abstract class in c#.net
What is difference between c and c sharp?
What is the difference between field and property in c#?
What are the types of access modifiers?
What is the base class for array types?
What is stringreader in c#?
Explain manifest & metadata in c#.
Can extension methods access private members?
Can a struct inherit from an interface in c#?
What is interface used in c#?