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
Why we use extension methods in c#?
Explain About Assembly in .NET, types of assemblies, their difference, How to register into GAC. How to generate the strong names & its use.
What are sorted lists?
What is new method in c#?
Explain get and set accessor properties?
Explain about finalize method?
What does void mean in c#?
How many types of collections are there in c#?
What is the difference between int and int in c#?
What is difference between Trace and Debug
What is a protected class in c#?
Can an array be null c#?
What is datetime parse in c#?
Can a string be null c#?
Is equal in c#?